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

November 17, 2010
By

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.

Be Sociable, Share!

Tags: , , , , ,

3 Responses to “ Nslookup resolves address but ping is unable to resolve hostname on Unix server ”

  1. Vijay on November 13, 2012 at 11:41 am

    You can try restarting NSCD service, this worked for me.

  2. showaid on April 21, 2012 at 2:55 am

    Thank you for easy fix!

  3. Sean Brady on December 5, 2010 at 8:31 pm

    I experience this same issue every time I setup a solaris virtual machine. Easy fix!

Leave a Reply