Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question

2 Answers 2

Looks like dnsmasq is starting correctly. You should test if dnsmasq is correctly working with nslookup test.local 127.0.0.1.

To make sure the system is using dnsmasq, you have to update the /etc/resolv.conf to use nameserver 127.0.0.1 as first option.

You can also use a custo upstream resolver configuration on dnsmasq with --resolv-file=/etc/resolv.conf.dnsmasq.

share|improve this answer
    
I have updated my question with some information based on your answer, I'd appreciate if you could take a look. –  user779159 Jul 21 at 16:17
    
Also the original /etc/dnsmasq.conf file is left as it was originally, with everything commented out. Are there things I need to uncomment from there? (It's a large file over 600 lines.) The only thing I uncommented was the last line conf-dir=/etc/dnsmasq.d because my custom config file is under that directory. –  user779159 Jul 21 at 16:21
    
Your dnsmasq is responding correctly. The conf-dir directive does load all files inside the directory, so you can have organize in different files, not necessary needed in your case. You can keep the original dnsmasq.conf as it is and put your configuration in a custom file in /etc/dnsmasq.d, as you've already done. You don't need sudo to run nslookup. Test again with nslookup test.local, it will use the DNS configuration from /etc/resolv.conf this time. –  dvm Jul 21 at 17:04
    
Please accept the answer if it suits your question. :) –  dvm Jul 22 at 2:34

If what you want only involves pointing back at your own machine, and not trying to use dnsmasq to control other computers' dns resolving, then what you want is to actually just add some entries in /etc/hosts. I'd recommenced you undo all your changes to dnsmasq and it's settings and make sure that /etc/hosts has the following at the top:

127.0.0.1 localhost
127.0.1.1 mycomputername mycomputername.local anothername.local

After this, pinging mycomputername.local will point to yourself (actually, will point to dnsmasq server running on 127.0.1.1, THEN to localhost). You can even add entries for other computers on your network so that it appears to you, on this machine, that computers can be referenced as computer1.local computer2.local etc.

192.168.1.31 computer1.local
192.168.1.32 computer2.local

If you can't seem to undo your changes with dnsmasq, then you can add those additional entries after localhost, but do not delete or change the localhost entry itself. So like this:

127.0.0.1 localhost mycomputername mycomputername.local anothername.local

BTW: the proper way to modify resolv.conf on Ubuntu desktop is with the network manager in your taskbar. The proper way in Ubuntu server is add dns-nameserver entries under your network device in /etc/network/interfaces and either restart or do ifdown eth0 && ifup eth0. As the warning in /etc/resolv.conf states, don't modify it directly, it gets written dynamically based on /etc/network/interfaces settings.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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