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)