Sign up ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

2 Answers 2

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

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.