Ubuntu – dnsmasq not working to point .local addresses to 127.0.0.1

dnsdnsmasqnetworkingUbuntu

I'd like to get .local addresses (such as test.local) to point to 127.0.0.1 but it isn't working. I'm on latest Ubuntu. In /etc/NetworkManager/NetworkManager.conf I commented out dns=dnsmasq then did sudo service network-manager restart.

I then installed dnsmasq and added a address=/local/127.0.0.1 to /etc/dnsmasq.d/mycustomfile then did sudo service dnsmasq restart. Apart from what I've mentioned I made no other changes.

But when I visit test.local it doesn't resolve to 127.0.0.1, doing a ping of that .local address also isn't successful. Maybe the contents of /etc/resolv.conf are relevant, it is just the default I didn't change it:

# 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 222.11.22.36
nameserver 222.11.22.37

This is the output when I run dnsmasq not as a daemon:

$ sudo dnsmasq --no-daemon     
dnsmasq: started, version 2.68 cachesize 150
dnsmasq: compile time options: IPv6 GNU-getopt DBus i18n IDN DHCP DHCPv6 no-Lua TFTP conntrack ipset auth
dnsmasq: reading /etc/resolv.conf
dnsmasq: using nameserver 222.11.22.37#53
dnsmasq: using nameserver 222.11.22.36#53
dnsmasq: read /etc/hosts - 9 addresses

When dnsmasq is running the /etc/resolv.conf automatically updates (and reverts back to the entry above when dnsmasq is stopped):

# 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.0.1

And this:

$ sudo nslookup test.local 127.0.0.1
Server:         127.0.0.1
Address:        127.0.0.1#53

Name:   test.local
Address: 127.0.0.1

But still doing a ping to localhost doesn't work.

What do I need to do to get dnsmasq working to resolve .local addresses?

Best Answer

  • local seem to be some kind of reserved keyword, at least on Ubuntu:

    • address=/local/127.0.0.1 -- doesn't work.
    • address=/loc/127.0.0.1 -- works.