1

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    
  • I'm inclined to believe this is a local configuration problem on your server. Your DNS server works is intended, as you have demonstrated. If your DHCP server hands out the DNS server address as the primary DNS server, then the client host should use that as a DNS server. The client can of course set up a local forwarding nameserver like dnsmasq that listens on address 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:45
  • What do you mean with "local (...) on your server". Is this a problem in the BIND configuration? – Laski Dec 28 '17 at 17:16
  • The name server works, as you have demostrated by using 192.168.1.5 as the server argument to nslookup. You said the DHCP server also hands out this address as the primary name server address, so that's OK too. But something has put 127.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 on 127.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:39
  • @JohanMyréen yes, it is dnsmasq (please see my last update to the question). So I need to reconfigure dnsmasq in every computer? – Laski Dec 29 '17 at 16:17
2

The 127.0.1.1 entry is most likely placed there by dnsmasq which is a local daemon for serving (and crucially caching) dns and dhcp. It's possible to configure NetworkManager to not run dnsmasq as follows: edit the file /etc/NetworkManager/NetworkManager.conf and comment out the line dns=dnsmasq by placing a # at the beginning of the line.

sudo nano /etc/NetworkManager/NetworkManager.conf

Now restart NetworkManager:

sudo service network-manager restart

Next check that the 127.0.1.1 entry has vanished from /etc/resolv.conf and replaced with those obtained from your router.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.