[CALUG] /etc/hosts not used?

Jim Bauer jfbauer at comcast.net
Sat Mar 18 12:35:16 CST 2006


On Saturday 18 March 2006 07:12, Eldon Ziegler wrote:
> I need a local host name to IP address association to override that
> provided by DNS. However, after entering the new definition in
> /etc/hosts the "host" command still returns the IP address from DNS.
> I've tried in on Linux 2.6 (RedHat ES4) and 2.4 (RedHat 9.x).
>
> /etc/host.conf has "order hosts,bind". /etc/nsswitch.conf has "hosts:
> files dns". Does some service need to be restarted? How do I get
> /etc/hosts to override DNS?

I am fairly certain the host command only does DNS lookups.
So it'll never look in /etc/hosts.

I think you really want to know what does the gethostbyname() library
routine will return?  Try this to find out (replacing 'foo' with what
you want to lookup).

perl -e '($x) = gethostbyname("foo"); print $x, "\n"'



More information about the lug mailing list