1

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  
foo

$hostname -f  
foo

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

$uname -n  
foo

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

$nslookup foo  
Server:     10.0.0.2  
Address:    10.0.0.2#53  
** 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 ?

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

2
  • 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? Commented Jan 30, 2014 at 3:49
  • From inside the vm (foo)
    – spuder
    Commented Jan 30, 2014 at 5:18

1 Answer 1

5

Its very simple, the DNS resolver (10.0.0.2) 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.

You must log in to answer this question.

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