• /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
    google.com has address
    $ nslookup google.com
    Non-authorative answer:
    Name:   google.com
    Name:   google.com
  • 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

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
  • 2
    Ideally you should copy /etc/nsswitch.dns over to /etc/nsswitch.conf, this is the normal and documented way to set up your system to use DNS, among creating the /etc/resolv.conf – BitsOfNix Jun 10 '13 at 15:00
  • It also depends how you installed Solaris. If at the interactive installer, or in sysidcfg, you specify DNS, nsswitch.conf should already be configured properly. – James O'Gorman Jun 10 '13 at 15:54
  • @AlexandreAlves Thanks, I have updated the answer. – Adam Siemion Jun 10 '13 at 16:44
  • @JamesO'Gorman Since I have very little experience with Solaris, I admit that maybe I missed it during the installation. But still it is really surprising that this is not set by default. – Adam Siemion Jun 10 '13 at 16:48
  • @AdamSiemion keep in mind that many of Solaris' largest customers are closed environments where DNS may not necessarily be used, and instead NIS holds sway. (or LDAP sometimes). Sun used to focus most of it's energy on it's top 50 customers. DNS stuff was added for the rest of their customers, but not made the default, because revenue from the top 50 > the rest. Oracle likely plays a similar game. – Tim Kennedy Jun 11 '13 at 13:01

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.

  • /usr/bin/host is another exception as it's a direct DNS client and does not use the Solaris name services. – alanc Jul 14 '17 at 23:01
root@solaris:~# svccfg -s name-service/switch
svc:/system/name-service/switch> setprop config/host = "files dns"
svc:/system/name-service/switch> listprop config
config                      application
config/default             astring     files
config/value_authorization astring     solaris.smf.value.name-service.switch
config/printer             astring     "user files"
config/host                astring     "files dns"
svc:/system/name-service/switch> exit
root@solaris11:~# svcadm refresh name-service/switch 
  • you can also update the DNS if there's still an issue solaris 10&11 – Michael James Perry Jul 13 '17 at 12:29
  • 1
    Can you explain your answer? Pasting some code do not make it good answer – Romeo Ninov Jul 13 '17 at 12:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.