In my linux machine, when I run hostname, it shows mongodb, but when I run host mongodb, it shows:
mongodb@mongodb:/var/hadoop/hadoop-1.2.1/bin$ host mongodb
Host mongodb not found: 2(SERVFAIL)
My /etc/hosts file:
192.168.10.10 mongodb
192.168.10.10 localhost
127.0.0.1 localhost
#127.0.0.1 localhost
# The following lines are desirable for IPv6 capable hosts
::1 ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
My first question is: Since
/etc/hostsis mapping from IP to hostname, why this machine cannot resolve the hostnamemongodbto IP 192.168.10.10? Instead, when I runhost localhost, it can be resolved and shows:localhost has address 127.0.0.1My another question: According to the
/etc/hostsfile, the hostnamelocalhostshould have been resolved to 192.168.10.10 instead of loopback IP address 127.0.0.1. Anybody can explain this to me?