Nslookup resolves address but ping is unable to resolve hostname on Unix server

I came across this issue on my newly built Solaris 10 server. I was able to ping a remote machine by Ip address, but not by its hostname. This indicated that I had the correct route and gateway. Using nslookup and dig I verified that the DNS servers were resolving the hostname to IP address. I confirmed that the file /etc/resolv.conf had the correct syntax for search domain-name.com.

Here is what my /etc/resolv.conf looks like, the two DNS servers are defined correctly as it the search domain.
domain andrewlin.com
namesserver 10.10.10.11
namesserver 10.10.11.13
search andrewlin.com

The gateway was defined in /etc/defaultrouter.
10.10.0.1
It seems that ping did not know how to resolve an address. I was also not able to surf the internet with the Firefox browser in the Sun Java Desktop System for Soalris. All symptoms indicated that the nsswitch.conf did not have the correct environment defined. The /etc/nsswitch.conf file defines which services are to used to retrieve information such as hostnames, password files, and group files. So in this case for the command ping and firefox which wants to resolve and address, it will check the nsswitch.conf file to see what services to use.

Below are the lines I changed in /etc/nsswitch.conf, by adding dns to the end of each lines.
hosts: files dns
ipnodes: files dns

I am now able to ping and surf the internet without any issues.

About Andrew Lin

Hi, I have always wanted to creat a blog site but never had the time. I have been working in Information Technology for over 15 years. I specialize mainly in networks and server technologies and dabble a little with the programming aspects. Andrew Lin

View all posts by Andrew Lin →