Issue : nslookup was working fine, but when pinging to a host, it says ping : Unknown host
Initially, I couldn't get domain names resolved in this specific node.
So, I created the resolv.conf file in /etc / location
root@~# vi /etc/resolv.conf
(In most of the OS's this file is already there, only you have to add name-servers)
Add DNS servers in the file as below
eg:
nameserver 8.8.8.8
nameserver 4.2.2.2
You can then check whether you can get domain names resolved, by the commands dig and nslookup
root@~#dig google.com
root@~# nslookup google.com
You will get some results for above commands. If not please check the resolv.conf file again.
------------------------------------------------------------------------------------------------------------------------
Next, I tried to ping google.com; it was saying that
root@~# ping google.com
ping: unknown host google.com
So, in this case, name resolution is working perfectly. But the issue is with the nsswitch, because it's configured only to check host file; dns is not checking. Below was the result for not working condition
/etc/nsswitch.conf:
hosts: files
# pretty much everything else set to files
Config should be as below to work
/etc/nsswitch.conf:
hosts: files dns
# pretty much everything else set to files
If you are using any other Open Source version, you can directly edit the file, but in Sun OS you have to edit it through the deamon.
So the question is how to make sure the Solaris Name Service knows that it has to lookup host names in both local files as well as in DNS. Remember that in Solaris 11 you are no longer supposed to / allowed to edit files such files as /etc/nsswitch.conf directly. They are controlled by daemons that run under SMF. Here is how to change it:
# svccfg
svc:> select name-service/switch
svc:/system/name-service/switch> setprop config/host = astring: "files dns"
svc:/system/name-service/switch> select system/name-service/switch:default
svc:/system/name-service/switch:default> refresh
svc:/system/name-service/switch:default> validate
svc:/system/name-service/switch:default> exit
# svcadm refresh name-service/switch
This should resolve domain resolving issue