Thursday, August 13, 2015

Solaris 10 - `host` and `nslookup` resolves hostnames while `ping` and `telnet` does not?

  • /etc/resolv.conf contains a nameserver that is alive (as reported by the ping command)
  • host or nslookup is able to resolve google.com

    $ host google.com
    google.com has address 74.125.228.3
    google.com has address 74.125.228.4
    ...
    $ nslookup google.com
    ...
    Non-authorative answer:
    Name:   google.com
    Address: 74.125.228.0
    Name:   google.com
    Address: 74.125.228.1
    ..
     
  • ping or telnet is not able to resolve google.com

    $ ping google.com
    ping: unknown host google.com
    
    $ telnet google.com
    google.com: node name or service name not known
     
     
    Fix Solution:
     
    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
     

No comments:

Post a Comment