Solaris

名稱解析不起作用,但 nslookup 可以

  • November 2, 2012

我在安裝 Solaris 11 時遇到了一個非常奇怪的問題。DNS 解析不起作用,但奇怪的是,nslookup 可以,並且連接性很好:

root@solarisxyz:~# ping stackexchange.com
ping: unknown host stackexchange.com
root@solarisxyz:~# nslookup stackexchange.com
Server:         10.x.x.x (DNS)
Address:        10.x.x.x#y

Non-authoritative answer:
Name:   stackexchange.com
Address: 64.34.119.12

root@solarisxyz:~# ping 64.34.119.12
64.34.119.12 is alive

文件的相關部分:

  • /etc/resolv.conf :(這和我們的 Linux 機器一樣)
domain us.oracle.com
nameserver 10.x.x.x
nameserver 10.x.x.x  
  • /etc/hosts
# ::1 solarisxyz localhost (commented out)
127.0.0.1 localhost loghost solarisxyz
  • /etc/nsswitch.conf :
hosts:    files dns
# pretty much everything else set to files

從 Solaris 11 開始,網路配置發生了根本性的變化。nsswitch.conf 現在只是提供資訊。假設您未處於自動模式,在這種情況下 DNS 已正確配置,以下是新過程:

http://docs.oracle.com/cd/E23824_01/html/E24456/gliyc.html#OSTELgllcu

使用 SMF 配置命名服務

以下範例顯示如何使用 SMF 命令配置 DNS。

# svccfg
svc:> select dns/client
svc:/network/dns/client> setprop config/search = astring: \
("us.company.com" "eu.company.com" "companya.com" "companyb.com" "company.com" )
svc:/network/dns/client> setprop config/nameserver = net_address: \
( 138.2.202.15 138.2.202.25 )
svc:/network/dns/client> select dns/client:default
svc:/network/dns/client:default> refresh
svc:/network/dns/client:default> validate
svc:/network/dns/client:default> 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> 
# svcadm enable dns/client
# svcadm refresh name-service/switch
# grep host /etc/nsswitch.conf
hosts:  files dns
# cat /etc/resolv.conf

引用自:https://unix.stackexchange.com/questions/24928