Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

ping tells me that it can't resolve some hostname ("ping: unknown host") in a URL but when I use host or nslookup on the same computer on the command line, the resolutions works fine (i.e. it's fast and reliable).

What could be causing this?

More testing: Firefox, wget and ping have the same problem. Pinging the IP address works.

OS: Linux (Ubuntu 13.04)

EDIT My /etc/resolv.conf reads:


netstat reports:

Proto Recv-Q Send-Q Local Address           Foreign Address         State       PID/Program name
tcp        0      0  *               LISTEN      -               

so something is running on this port (nslookup also reports it uses as DNS server).

There is no /etc/*inetd.conf, so I'm not sure which application serves this port.

It seems that dnsmasq is used:

/usr/sbin/dnsmasq --no-resolv --keep-in-foreground --no-hosts --bind-interfaces
   --pid-file=/var/run/NetworkManager/ --listen-address=
   --conf-file=/var/run/NetworkManager/dnsmasq.conf --cache-size=0 --proxy-dnssec

All the config files and folders are empty. Since nslookup says it uses my guess is that dnsmasq works even without a configuration. But how does it know which parent DNS to query?

EDIT2 Disabling dnsmasq as suggested by harrymc didn't help. So I ran strace ping which gave me this odd output (just the interesting parts):

open("/etc/host.conf", O_RDONLY|O_CLOEXEC) = 4
read(4, "\tlocalhost\n#\ta"..., 4096) = 613
open("/lib/", O_RDONLY|O_CLOEXEC) = 4
read(4, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\0\f\0\0\0\0\0\0"..., 832) = 832
mmap(NULL, 2105560, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 4, 0) = 0x7f7829b00000
socket(PF_FILE, SOCK_STREAM, 0)         = 4
fcntl(4, F_GETFD)                       = 0
fcntl(4, F_SETFD, FD_CLOEXEC)           = 0
connect(4, {sa_family=AF_FILE, path="/var/run/avahi-daemon/socket"}, 110) = 0
fcntl(4, F_GETFL)                       = 0x2 (flags O_RDWR)
fstat(4, {st_mode=S_IFSOCK|0777, st_size=0, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f782a4f8000
lseek(4, 0, SEEK_CUR)                   = -1 ESPIPE (Illegal seek)
write(4, "RESOLVE-HOSTNAME-IPV4"..., 44) = 44
read(4, "-15 Timeout reached\n", 4096)  = 20

So ping looks in /etc/hosts which makes sense. Then it loads and mmap()s /lib/ which makes sense as well.

But then it talks to avahi!?

Which led me to this forum post: ping doesn't make a dns request.

My /etc/nsswitch.conf also contains this line:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4

If I ping a working address, I see that the process also loads /lib/ but then, it does a DNS query via port 53.

So my guess is now that /lib/ is somehow noticing that the IP address ends with .local and not with .com and then the [NOTFOUND=return] is triggered.

How do I fix this?

share|improve this question
What's in your /etc/resolv.conf? – Joseph R. Jan 21 '14 at 12:23
Which is correct and which is incorrect? Should the hostname resolve or shouldn't it? You didn't tell us which of two completely different problems you have. (And if it should resolve, explain in as much detail as possible how and why it should resolve, as that will likely lead to the explanation of why it doesn't.) – David Schwartz Jan 21 '14 at 12:43
... and what your HTTP proxy settings are for Chrome, Firefox, and wget. – JdeBP Jan 21 '14 at 13:27
@DavidSchwartz: I'm expecting resolution to work. What I don't understand how nslookup or host can resolve the name and anything else on the system can't. – Aaron Digulla Jan 21 '14 at 15:39
If you are not doing connection sharing with other devices or VMs thru your computer, you could turn off dnsmasq in Network Manager. Edit /etc/NetworkManager/NetworkManager.conf and comment the dns=dnsmasq line (put a # in front of it) then do a sudo restart network-manager. That will turn off the local resolver. (source) – harrymc Jan 24 '14 at 10:58
up vote 16 down vote accepted

As described in detail in this blog post, you need to edit /etc/avahi/avahi-daemon.conf:


This binds the daemon to the domain .alocal instead of the default .local.

and restart the daemon with:

sudo service avahi-daemon restart

Note from the blog post:

You may need to flush the DNS,mDNS and resolver cache, as well as restart your web browsers to clear their internal cache.

After that, ping and nslookup started to agree.

Thanks to harrymc for getting me on the right track.

share|improve this answer
Also note, ping will use nss, nslookup does not. (it uses lwres and, well, bind, to talk to directly with a resolver) – Ricky Beam Jan 28 '14 at 1:25
For me it does more sense to configure it right instead of disabling it for local. – keiki Jul 28 '14 at 8:44
@otakun85: And how would I do that? – Aaron Digulla Jul 28 '14 at 8:46
@AaronDigulla You configured it and the current highest voted answer disabled it for local. – keiki Jul 28 '14 at 9:16
@otakun85: Ah, I get it. I've accepted this answer instead. – Aaron Digulla Jul 28 '14 at 10:00

Easy thing to do: Edit /etc/default/avahi-daemon

Change the line:




Restart the avahi-daemon, or kill it.

I don't like Avahi, and I don't use any of its features. If you want to truly disable avahi, modify /etc/init/avahi-daemon.conf, similar to the following:

start on (never 
          and filesystem
      and started dbus)
stop on stopping dbus
share|improve this answer
I don't care if you aren't supposed to put "thanks" comments here, I just wanted to express my thanks and how much time and energy you saved me. Thank you so much! I'm using a company VPN to do some emergency work from a mall and could not get some of our sites working despite everything I thought of trying. I wouldn't have been able to figure this out on my own, that's for sure... – eresonance Nov 20 '14 at 16:43

If you are not doing connection sharing with other devices or VMs thru your computer, you could turn off dnsmasq in Network Manager.

Edit /etc/NetworkManager/NetworkManager.conf and comment the line (put a # in front of it) :


Then do :

sudo restart network-manager

That will turn off the local resolver.

Source: DNS in Ubuntu 12.04.

share|improve this answer

Modifying /etc/nsswitch.conf and replacing:

hosts:          files mdns4_minimal [NOTFOUND=return] dns mdns4


hosts:          files dns

worked for me.

share|improve this answer
This works at the cost of the AVAHI services – Aaron Digulla Apr 9 '15 at 7:42

it seems .local address can't be access in ubuntu.

a solution is to edit /etc/nsswitch.conf and change this line :

hosts:          files mdns4_minimal [NOTFOUND=return] dns

by this :

hosts:          files dns
share|improve this answer

Another reason is the format of /etc/hosts. Make sure there are no spaces between IP and host name, instead use a TAB. After changing to TAB the host name could be resolved by ping.        test.local
         ^^^^^^^^ → Should be a TAB not multiple spaces.
share|improve this answer
it could be an answer but it is formatted as comment ... – Francisco Tapia Jul 9 '15 at 12:44

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .