== Multihomed hosts and _/etc/hosts_ As a side note to [[looking up hostnames from IP addresses ../programming/ReverseDNS]] for people who use _/etc/hosts_, note that _/etc/hosts_ lookups work badly in the presence of hosts with multiple IP address, since most _gethostbyname()_ implementations will only return the first IP address that they find in _/etc/hosts_. These days you really want a minimal _/etc/hosts_ and a reliable DNS server, unless you have [[special concerns MinimalHostnames]]. (The _gethostbyname()_ behavior is sensible, since otherwise it would always have to scan the entire _/etc/hosts_ file just to make sure that it had found all IP addresses for a host, even when most hosts only have one IP address.) While there are workarounds for this issue, I think that the best way out is just to not have any entries for your multihomed hosts in _/etc/hosts_, even on the hosts themselves. This appears to work fine on at least modern Linuxes, and I can't imagine that the *BSDs do any worse here. (You can have similar behavior with _gethostbyaddr()_, depending on how you give an IP address multiple names in _/etc/hosts_. Putting all the names on one line works out, but having multiple lines for one IP address has the same problem.)