I have a centOS system(embedded and has very binaries) with the following /etc/hosts.
$cat /etc/hosts
127.0.0.1 localhost localhost
Also the host is assigned a DNS server which returns some invalid IP for the domain name lookup of localhost. But I cannot avoid a connection to this DNS due to some network restrictions.
My question is, when I already have a valid /etc/hosts file why is the system querying the DNS for localhost? And how can I stop that?
Any help would be greatly appreciated.
Check that you have files
listed before dns
for the hosts
entry in /etc/nsswitch.conf
.
[me@home]$ grep "^hosts" /etc/nsswitch.conf
hosts: files dns
If dns
comes first, then your system will always query DNS to resolve hostnames before falling back to /etc/hosts
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With