Operating System - Linux
1828047 Members
2110 Online
109973 Solutions
New Discussion

default behavior config for host resolution

 
SOLVED
Go to solution
Maaz
Valued Contributor

default behavior config for host resolution

Hello All
Two files sets the default behavior for host resolution
i, /etc/nsswitch.conf
ii, /etc/host.conf
OK

If I want to config that first check with Dns server then local hosts file ... I have to configure both files ?
As,
in nsswitch.conf
hosts: dns file
and in host.conf
order bind,hosts

or which file have more precedenc/priority ?
that is if in case if there is a conflict e.g
in nsswitch.conf
hosts: files dns
and in host.conf
order bind,hosts

Plz Guide me
Regards
4 REPLIES 4
Alexander Chuzhoy
Honored Contributor
Solution

Re: default behavior config for host resolution

I never touch the /etc/host.conf file.
I edit the /etc/nsswitch.conf file.
And in your case first the check is done against the DNS (thus you must edit the file /etc/resolv.conf and to make sure that the correct DNS server appears there. It looks like this: nameserver x.x.x.x).
Then the check is done against the /etc/hosts.file.

Best practice is to put "files" before the DNS, so if there's something particular that you need only your host to resolv and the same hostname appears in DNS -you can simply add it to /etc/hosts file and that's it.

Best regards.
Alexander Chuzhoy
Honored Contributor

Re: default behavior config for host resolution

Sergejs Svitnevs
Honored Contributor

Re: default behavior config for host resolution

Maaz,

The older glibc library configured host lookup ordering in the /etc/host.conf. This library is now obsolete and useless. Version 2 of the GNU standard library, glibc, uses /etc/nsswitch.conf.

Your system will probably provide host.conf for compatibility to enable older programs linked against the older library.

Regards
Maaz
Valued Contributor

Re: default behavior config for host resolution

Very Nice help dear Alexander Chuzhoy and Sergejs Svitnevs ;)
Thanks a Million for such a promtp help

Regards
Maaz