Operating System - HP-UX
1833289 Members
2993 Online
110051 Solutions
New Discussion

Re: /etc/hosts fisrt, after DNS

 
malki_3
Frequent Advisor

/etc/hosts fisrt, after DNS

I want to configure nsswitch to give a resolution first throught /et/hosts after with DNS. How can I do it.
I dont now if it was a solution for a big late that I have with when I use this DNS configuration
#cat /etc/resolv.conf
domain DOM.com
nameserver 10.1.2.3 #Primary
nameserver 10.1.2.4 #Secondary
Thanks fo all


6 REPLIES 6
Steven Sim Kok Leong
Honored Contributor

Re: /etc/hosts fisrt, after DNS

Hi,

In /etc/nsswitch.conf,

hosts: files [NOTFOUND=continue] dns

Hope this helps. Regards.

Steven Sim Kok Leong
U.SivaKumar_2
Honored Contributor

Re: /etc/hosts fisrt, after DNS

Hi,
create /etc/nsswitch.conf file with a single line.
hosts: files [NOTFOUND=continue] dns
Have your resolv.conf as usual. This setup will
serve your purpose.
#man nsswitch.conf

regards,
U.SivaKumar
Innovations are made when conventions are broken
Shahul
Esteemed Contributor

Re: /etc/hosts fisrt, after DNS

Hi

Ur /etc/nsswitch.conf can be like this

hosts: files [NOTFOUND=continue, TRYAGAIN=continue] dns nis

Normally this file will be there.. U will have to just edit only...

Best of luck
Shahul
Sanjay_6
Honored Contributor

Re: /etc/hosts fisrt, after DNS

Hi Malki,

In your /etc/nsswitch.conf file try this entry,

hosts: files [NOTFOUND=continue] dns

then try,

nslookup
> server_name (exist in /etc/hosts)
> server_name (does not exist in /etc/hosts /exists in DNS)

Hope this helps.

Regds

malki_3
Frequent Advisor

Re: /etc/hosts fisrt, after DNS

I have this configuration
#
hosts: dns [NOTFOUND=continue] files
it's wrong config I taink..
I must switch like you have explaining
Pete Randall
Outstanding Contributor

Re: /etc/hosts fisrt, after DNS

Malki,

You're right - as you've shown your nsswitch file, DNS would be tried first and, only if the DNS lookup failed, the hosts file would be consulted next.

Good Luck,
Pete

Pete