I've configured a computer to act as a DNS server for my LAN (following roughly this guide). My main motivation is to be able to access my computers and appliances with URLs instead of IPs.
It's working and forwarding OK, as I'm able to resolve correctly my own names:
➜ ~ nslookup router.casa 192.168.1.5
Server: 192.168.1.5
Address: 192.168.1.5#53
Name: router.casa
Address: 192.168.1.1
and outside ones:
➜ ~ nslookup google.com 192.168.1.5
Server: 192.168.1.5
Address: 192.168.1.5#53
Non-authoritative answer:
Name: google.com
Address: 172.217.28.174
(192.168.1.5
, as you probably already discovered, is the DNS server address)
I've then setup the DHCP server (a Linksys router) to hand out 192.168.1.5
as the primary DNS address, and Google ones next. That's because I'd like my devices to be able to resolve names even if the local DNS server is down. This also seems to be working, or at least is correctly reflected in any PC when I do
➜ ~ nmcli dev show | grep DNS
IP4.DNS[1]: 192.168.1.5
IP4.DNS[2]: 8.8.8.8
IP4.DNS[3]: 8.8.4.4
However, normal nslookup
queries (without explicit DNS address) do not work:
➜ ~ nslookup router.casa
Server: 127.0.1.1
Address: 127.0.1.1#53
** server can't find router.casa: NXDOMAIN
After reading many SuperUser, Unix & Linux and AskUbuntu questions, I now know that this 127.0.1.1
address is something like a local DNS cache setup by default by resolvconf
, which comes pre-configured for that in my distro (Mint). Effectively:
➜ ~ cat /etc/resolv.conf
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
nameserver 127.0.1.1
I've read many (accepted) solutions recommending some manual patches (either editing the resolv.conf base files, removing resolvconf entirely, etc.). However, I would like any guest device to be able to use the local names, and I really don't want to edit the entire LAN settings (some of the devices are not mine).
Is there any way to configure the DNS server and/or the DHCP so that I don't have to edit all PCs' and devices' settings manually?
Also, as a side question, why is this 127.0.1.1 server ignoring the first DNS address? nslookup
fails even when I use it from the DNS server:
➜ ~ nslookup router.casa 127.0.0.1
Server: 127.0.0.1
Address: 127.0.0.1#53
Name: router.casa
Address: 192.168.1.1
➜ ~ nslookup router.casa 127.0.1.1
Server: 127.0.1.1
Address: 127.0.1.1#53
** server can't find router.casa: NXDOMAIN
More useful output:
➜ ~ sudo netstat -tulpn | grep 127.0.1.1
tcp 0 0 127.0.1.1:53 0.0.0.0:* ESCUCHAR 1489/dnsmasq
udp 0 0 127.0.1.1:53 0.0.0.0:* 1489/dnsmasq
127.0.1.1
, or whatever, but in this case the client alone is responsible that this setup works. – Johan Myréen Dec 24 '17 at 20:45BIND
configuration? – Laski Dec 28 '17 at 17:16192.168.1.5
as the server argument tonslookup
. You said the DHCP server also hands out this address as the primary name server address, so that's OK too. But something has put127.0.1.1
in/etc/resolv.conf
, probably a local forwarding resolver like dnsmasq? By local problem I mean this something hasn't done its job properly, as nothing seems to be listening on127.0.1.1
, or if some program is listening, it isn't forwarding requests to the proper name server. – Johan Myréen Dec 28 '17 at 19:39dnsmasq
(please see my last update to the question). So I need to reconfigurednsmasq
in every computer? – Laski Dec 29 '17 at 16:17