[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: /etc/hosts vs dns server



Joel Taqueban wrote:
> 
> dear admins
> 
> how do i tell my linux box to look into my /etc/hosts file first
> before looking into a dns server when resolving an IP address or
> hostname?
> 
> i've edited the /etc/resolv.conf and looked into /etc/nsswitch.conf
> 
> particularly i have this entries on /etc/nsswitch.conf:
> 
> 
>      passwd:     files nisplus nis
>      shadow:     files nisplus nis
>      group:      files nisplus nis
> 
>      hosts:      files nisplus nis dns
> 
>      services:   nisplus [NOTFOUND=return] files
>      networks:   nisplus [NOTFOUND=return] files
>      protocols:  nisplus [NOTFOUND=return] files
>      rpc:        nisplus [NOTFOUND=return] files
>      ethers:     nisplus [NOTFOUND=return] files
>      netmasks:   nisplus [NOTFOUND=return] files
>      bootparams: nisplus [NOTFOUND=return] files
> 
>      netgroup:   nisplus
> 
>      publickey:  nisplus
> 
>      automount:  files nisplus
>      aliases:    files nisplus
> 
> 
> 
> Anything I need to change from the above so the my system looks into
> /etc/hosts file first before my dns?
> 
> Joel
Hi Joel,

the /etc/nsswitch.conf file specifies the 'search order' for various
services. If you do not run NIS or NIS+ it's wise to delete these
entries in nsswitch.conf. To force Linux to consult the local /etc/hosts
file before dns put the following line into your nsswitch.conf (or edit
it if it already exists)

hosts:	files dns

If you run NIS or NIS+ you may also append 'nis' or 'nisplus'  to the
line above.

I also used to edit /etc/host.conf as follows:

order hosts,bind
multi on

I can remember a bug in previous libc versions where nsswitch.conf was
ignored for some hostname/ip lookups (the effect was my linux box did
_always_ a dns lookup first before consulting the /etc/hosts file if dns
was enabled!) But this should be fixed with glibc-2.1

bye and best regards
Thomas
-- 
Ing. Thomas Mandl            

System and Network Administrator     phone: +43 1 877 56 45/53
Thomas NEUROTH Ges.m.b.H.              fax: +43 1 876 49 20
Hietzinger Hauptstrasse 22          e-mail: Thomas Mandl neuroth co at
A-1130 Vienna/Austria              NIC-HDL: TM4373, RIPE-HDL: TM539-RIPE



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]