Skip to main content
added 45 characters in body
Source Link
heemayl
  • 58.1k
  • 9
  • 129
  • 144

This is dictated by the NSS (Name Service Switch) configuration i.e. /etc/nsswitch.conf file's hosts directive. For example, on my system:

hosts: files mdns4_minimal [NOTFOUND=return] dns 

Here, files refers to the /etc/hosts file, and dns refers to the DNS system. And as you can imagine whichever comes first wins.

Also, see man 5 nsswitch.conf to get more idea on this.


As an aside, to follow the NSS host resolution orderings, use getent with hosts as database e.g.:

getent hosts example.com 

This is dictated by the /etc/nsswitch.conf file's hosts directive. For example, on my system:

hosts: files mdns4_minimal [NOTFOUND=return] dns 

Here, files refers to the /etc/hosts file, and dns refers to the DNS system. And as you can imagine whichever comes first wins.

Also, see man 5 nsswitch.conf to get more idea on this.


As an aside, to follow the NSS host resolution orderings, use getent with hosts as database e.g.:

getent hosts example.com 

This is dictated by the NSS (Name Service Switch) configuration i.e. /etc/nsswitch.conf file's hosts directive. For example, on my system:

hosts: files mdns4_minimal [NOTFOUND=return] dns 

Here, files refers to the /etc/hosts file, and dns refers to the DNS system. And as you can imagine whichever comes first wins.

Also, see man 5 nsswitch.conf to get more idea on this.


As an aside, to follow the NSS host resolution orderings, use getent with hosts as database e.g.:

getent hosts example.com 
Source Link
heemayl
  • 58.1k
  • 9
  • 129
  • 144

This is dictated by the /etc/nsswitch.conf file's hosts directive. For example, on my system:

hosts: files mdns4_minimal [NOTFOUND=return] dns 

Here, files refers to the /etc/hosts file, and dns refers to the DNS system. And as you can imagine whichever comes first wins.

Also, see man 5 nsswitch.conf to get more idea on this.


As an aside, to follow the NSS host resolution orderings, use getent with hosts as database e.g.:

getent hosts example.com