On a test VM, I have setup the /etc/hosts to resolve the machine name.

Why is it that nslookup is unable to find the server?


$hostname -f  

$cat /etc/hosts   foo   foo.openstacklocal sdb nid01 nid02 nid03 nid04     localhost localhost.localdomain localhost4 localhost4.localdomain4  
::1   localhost localhost.localdomain localhost6 localhost6.localdomain6

$uname -n  

$ping foo  
PING foo ( 56(84) bytes of data.  
64 bytes from foo ( icmp_seq=1 ttl=64 time=0.028 ms  

$nslookup foo  
** server can't find foo: NXDOMAIN 

My understanding of nslookup is that is should query the dns server (or /etc/hosts) to find the machine name.

Why in this case am I unable to resolve foo ?

All these commands are run from inside the vm (foo)

  • 1) Are you trying to resolve the VM's name from the host? Or the host's name from the VM? 2) How is th VM connected to the Host? – MariusMatutiae Jan 30 '14 at 3:49
  • From inside the vm (foo) – spuder Jan 30 '14 at 5:18

Its very simple, the DNS resolver ( does not have an entry for foo.

nslookup does not consider /etc/hosts, it is specifically to check for DNS entries against name servers (thats the ns in nslookup).

Since your DNS server does not have an entry for foo, the name resolution fails.

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.