6
  • /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
    

3 Answers 3

9

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
5
  • 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, 2013 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. Jun 10, 2013 at 15:54
  • @AlexandreAlves Thanks, I have updated the answer. Jun 10, 2013 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. Jun 10, 2013 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. Jun 11, 2013 at 13:01
4

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.

1
  • /usr/bin/host is another exception as it's a direct DNS client and does not use the Solaris name services.
    – alanc
    Jul 14, 2017 at 23:01
0
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 
2
  • you can also update the DNS if there's still an issue solaris 10&11 Jul 13, 2017 at 12:29
  • 1
    Can you explain your answer? Pasting some code do not make it good answer Jul 13, 2017 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.