Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

My understanding is that the unix ping and host commands should generate the same IP address given the same domain. If you look at these two commands:

$ ping
PING ( 56 data bytes
64 bytes from icmp_seq=0 ttl=64 time=0.303 ms

$ host has address

The first is my local development VM, and shows the desirable IP as I've specified in my /etc/hosts file. The second shows the live box, circumventing my /etc/hosts file. I have flushed my DNS cache to verify that's not causing the difference.

share|improve this question
up vote 2 down vote accepted

the host command (and nslookup command) ignore /etc/hosts, as you've found. They work against nameservers (DNS), not local files.

pretty sure getent ahosts (host) will also use /etc/hosts, like ping does.

share|improve this answer

Host is a dns query application and does not look in the hosts file. See

share|improve this answer

You must log in to answer this question.

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