I'm setting up a local network and have configured a DNS server. I can resolve hostnames by querying the DNS server, but no programs can look them up.

I uninstalled libnss-mdns and removed avahi-daemon and even rebooted afterwards.

Here are some examples:

root@cloud2:~# host ns.example.com
ns.example.com has address
root@cloud2:~# ping ns.example.com
ping: unknown host ns.example.com

root@cloud2:~# grep hosts /etc/nsswitch.conf 
hosts:          files dns

my ntp server is configured for ns.example.com, but all I get is nxdomain on ntpq

any ideas?


This also applies to external DNS entries. I have my router both as a DNS forwarder on the custom DNS server and as an entry in resolvconf.


root@cloud2:~# host google.com | head
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
google.com has address
root@cloud2:~# traceroute google.com
google.com: Temporary failure in name resolution
Cannot handle "host" cmdline arg `google.com' on position 1 (argc 1)
  • 2
    Odd. Please add the content of your /etc/resolv.conf file. Also mention which Ubuntu release you are running. – jdthood Jan 25 '13 at 12:56
  • DNS cache such as named or sssd caching negative lookups? – Steve-o Jan 25 '13 at 14:53
  • @Steve-o I had looked for DNS caching, I've been burned plenty of times by nscd in the past so that's a good suggestion :-) – zje Jan 25 '13 at 16:45
  • @jdthood Good suggestion! It was resolv.conf that was the culprit - see answer below – zje Jan 25 '13 at 16:46

This was on Ubuntu server 12.04 LTS and Ubuntu 12.04 LTS

Thanks all for the help. Turns out to be a result of a difference in the way host and the glibc resolver read /etc/resolv.conf.

I was managing resolv.conf with a puppet module that edited the appropriate files in /etc/resolvconf/resolv.conf.d/.

Said puppet module resulted in an /etc/resolv.conf that looked like this:


 search example.com

with a space at the beginning of each line. After removing these spaces, I was able to resolve with both ping and manual lookups (host/nslookup/etc...)

I could've sworn that I've had those spaces on other OSes with no issues, but I just tried on a SL6.3 box and it caused the same behavior.

Thanks for your help and sorry for the trouble!

  • I don't see any unusual spaces in the earlier resolv.conf. – jdthood Jan 26 '13 at 6:56
  • By the way, is this a custom Puppet module or one you got from somewhere else? If the latter then we should see to it that the bug gets fixed upstream. – jdthood Jan 26 '13 at 6:58
  • The unsual spaces are leading spaces, which might be tricky to see given the way the gray boxes are. (I realize you've probably noticed, but I want to leave this question for posterity). Also, this is what I baesd my module on: danielhelm.com/blog/60-puppet-dns-client-module, but remember that ubuntu uses the resolvconf service - so I edited /etc/resolvconf/resolv.conf.d/head I'm putting a comment on that site... – zje Jan 26 '13 at 17:29
  • I have edited the answer (pending acceptance) so as to make it clearer that there are spaces at the beginnings of the lines. I consider this to be a shortcoming in the glibc resolver; it should ignore leading whitespace, especially if host does so. – jdthood Jan 26 '13 at 21:25
  • I left a comment on that site too. I also filed a wish in the Debian BTS (#699061) requesting that leading whitespace be ignored in resolv.conf. – jdthood Jan 26 '13 at 22:13

You need to supply dns config for each connection type you have.

Network Manager is your friend (or if you are using DHCP, then configure your DNS there)

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.