Why `host` and `nslookup` on Solaris 10 resolves hostnames while `ping` and `telnet` does not?
It seems ping
and telnet
were unable to resolve hostnames, because they were not querying the configured DNS server (host
and nslookup
seem to be using different DNS querying code), the solution is to:
Overwrite /etc/nsswitch.conf
with /etc/nsswitch.dns
:
cp /etc/nsswitch.dns /etc/nsswitch.conf
Adam, you do not tell us what version of Solaris you're using.
All host lookup on Solaris goes through the Solaris Naming Service daemon. The only exception is nslookup
which does a direct DNS query against a DNS server. The Naming Service daemon basically acts as a cache of naming information. Other operating systems have similar services. The Solaris Naming Service is configured in the /etc/nsswitch.conf
file.
I really, really hope you are on an older version, such as Solaris 10 or before. Otherwise you've now manually edited a file you are no longer supposed to edit : the /etc/nsswitch.conf
file.
Anyway, lets say you are on Solaris 10 or older:
Your /etc/nsswitch.conf
should have an entry like this:
hosts: files dns
This tells the Solaris Naming Service that hosts should be looked up first in the local file (i.e. /etc/hosts
) and then in DNS. You can of course also only have "dns" here but people will normally want it so that /etc/hosts
can override what is in DNS.
You may now have to restart the naming service daemon:
svcadm restart /system/name-service-cache
You can always verify your naming service setup with the Solaris getent
command:
getent hosts google.com
The getent
command verifies that the Solaris Naming Service works as you expect. You cannot use nslookup
to verify this.
If your are on Solaris 11 then you can use nolan600's answer to this question. The getent
command also applies to Solaris 11.
Hope you can use some of this.