On host01
, if we have an entry for app01
in /etc/hosts
file like 172.168.238.12 app01
and the DNS server which is used by host01
has 172.168.239.10
as app01's
IP then which IP host01
will pick for app01
as per priority.
Hi @Thulasiram
The /etc/hosts
file is a local configuration file that maps hostnames to IP addresses. The operating system’s name resolution mechanism first consults it before querying external DNS servers.
Hope this helps!
could you please solve the question in step by step
Priority is controlled by a line in /etc/nsswitch.conf
like this
hosts: files dns
-
hosts
is the line concerning DNS loookup -
files
means the file/etc/hosts
-
dns
means use the configured DNS server.
In the above example it is configured to look first in the hosts file, and if the entry is not there, then use DNS server. If the order is dns files
then it will use DNS server first. That is all there is to it.