Force Use of HOST file

From The System Administrator Zone


On Linux systems, the host lookup function (gethostbyname) always use BIND for hostname resolution. To get the system to look at /etc/hosts first for the entry labelled hosts: in the file /etc/nsswitch.conf.

The default setting, normally used it the nsswitch.com file is missing is;

  • hosts: dns [!UNAVAIL=return] files

Change is to something more usable;

  • hosts: files dns

The [!UNAVAIL=return] in the default ensures that it never looks at the host file.