cancel
Showing results for 
Search instead for 
Did you mean: 

Re: /etc/nsswitch.conf

 
SOLVED
Go to solution
Shivkumar
Super Advisor

/etc/nsswitch.conf

Dear Sirs;
I saw the below entry in /etc/nsswitch.conf:-

hosts: files [NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]

Looks like this is configured wrongly .. i guess ideally resolution should first take place through dns only.

Appreciate your suggestions.

Thanks,
Shiv
6 REPLIES 6
Patrick Wallek
Honored Contributor
Solution

Re: /etc/nsswitch.conf

That looks fine to me. That should be the preferred way. You want to be able to do quick lookups of things like localhost or the machine own name/IP address. Have files first will make this very quick.

Looking up in hosts first will take very little time, and if the name / IP address is not found then it will go to DNS.

If you have only DNS configured, what happens if your DNS server(s) are down? You would be out of luck with any name lookups.
Raj D.
Honored Contributor

Re: /etc/nsswitch.conf

Hi Shiv ,

It configured correctly, and this is the normal sequence for host resolution ,

When DNS confugured and exists , it tries to resolve using DNS , and cheks local data file for hostname , if found it resolves --> Else , requests a root name server to provide server address that can resolve the host name.


Here is another sample file:
# cat /etc/nsswitch.conf
hosts: files [NOTFOUND=continue UNAVAIL=continue TRYAGAIN=continue] dns[NOTFOUND=return UNAVAIL=return TRYAGAIN=return]
protocols: files[NOTFOUND=return UNAVAIL=continue]
services: files[NOTFOUND=return UNAVAIL=continue]
...

Cheers,
Raj.
" If u think u can , If u think u cannot , - You are always Right . "
Bill Hassell
Honored Contributor

Re: /etc/nsswitch.conf

As mentioned, this is the preferred method. There are two reasons:

- If your DNS server is not up to date, you can fix it in your local hosts file. You don't need to put thousands of names/IPs in this file, only ones that you need immediately.

- The /etc/hosts file is always in memory and many commercial backup program insist on querying the nameserver for EVERY file (very questionable design). This can have a heavy impact on the DNS server, especially if many systems are all backing up at the same time. /etc/hosts with all the IP addresses used in the backup program will no go to the DNS server.

So, files then dns is preferred.


Bill Hassell, sysadmin
Arunvijai_4
Honored Contributor

Re: /etc/nsswitch.conf

Shiv, It is normal way of configuring /etc/nsswitch.conf file. Nothing wrong with that. It goes to /etc/hosts then to DNS. You will get faster performance.

-Arun
"A ship in the harbor is safe, but that is not what ships are built for"
Mahesh Kumar Malik
Honored Contributor

Re: /etc/nsswitch.conf

Hi Shiv

1. It depends on name resolution policy in IT setup. If you have hosts entry in /etc/hosts file then above entry will look for this file first and then dns

2. If dns is used for name resolution then above entry is perfect. In such case you may modify the entry to look for dns only as per following:

hosts: * files [NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]

Regards
Mahesh
Muthukumar_5
Honored Contributor

Re: /etc/nsswitch.conf

Based on /etc/nsswitch.conf setting only hostname -> ip or ip->hostname and passwd or network will be getting resolved.

hosts: files [..] dns [..]

It will try to start resolvation from /etc/hosts then /etc/resolv.conf's nameserver settings.

If you want to set correct setting then use nsquery command as,

# nsquery hosts "files [NOTFOUND=continue UNAVAIL=continue] dns [NOTFOUND=return UNAVAIL=continue TRYAGAIN=return]"

It will give result to you.

I feel you can simply use like,

hosts: dns files

hth.

Easy to suggest when don't know about the problem!