Take the 2-minute tour ×
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 api.dev.myserver.com
PING api.dev.myserver.com (10.11.12.15): 56 data bytes
64 bytes from 10.11.12.15: icmp_seq=0 ttl=64 time=0.303 ms
(...)

$ host api.dev.myserver.com
api.dev.myserver.com has address 69.68.153.135

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
add comment

2 Answers

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
add comment

Host is a dns query application and does not look in the hosts file. See http://linux.die.net/man/1/host

share|improve this answer
add comment

Your Answer

 
discard

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.