Ubuntu

正確的 DNS 後綴設置 Ubuntu 17.04?

  • August 29, 2017

我無法讓 DNS 後綴正常工作

基本上,我已經jira.mycompany.local在公司的 DNS 伺服器上映射到192.168.100.5

我希望能夠同時使用jira和訪問它jira.mycompany.local

我有這個在我的/etc/systemd/resolvd.conf

[Resolve]
Domains=mycompany.local devnet.mycompany.nl

重新啟動網路管理器並解決:

systemctl restart NetworkManager.service
systemctl restart systemd-resolved.service 

結果/etc/resolv.conf

nameserver 192.168.10.1
nameserver 192.168.10.2
nameserver 127.0.0.53

search mycompany.local
search devnet.mycompany.nl

所以這一切看起來都很好。測試DNS:

nslookup jira.mycompany.local
Server:     192.168.10.1
Address:    192.168.10.1#53

Name:   jira.mycompany.local
Address: 192.168.100.5

ping 到 IP:

>ping 192.168.100.5
PING 192.168.100.5 (192.168.100.5) 56(84) bytes of data.
64 bytes from 192.168.100.5: icmp_seq=1 ttl=63 time=7.04 ms

Ping To 主機名(帶和不帶後綴):

>ping jira
ping: jira: Name or service not known

>ping jira.mycompany.local
ping: jira.mycompany.local: Name or service not known

相關行 /etc/nsswitch.conf

hosts:          files [NOTFOUND=return] resolve [!UNAVAIL=return] dns myhostname

(我刪除了 avahi 線,所以它不會干擾。)

使用探勘測試:

dig +short jira 
(empty)

dig +short jira.mycompany.local 
192.168.100.5

$$ EDIT $$ 我修改了 etc/nsswitch.conf 中的 hosts 行:

hosts:          files resolve dns

現在:

>ping jira.mycompany.local
PING jira.mycompany.local (192.168.100.5) 56(84) bytes of data.
64 bytes from 192.168.100.5: icmp_seq=1 ttl=63 time=7.04 ms

有效,但是:

>ping jira
ping: jira: Temporary failure in name resolution

我怎樣才能調試這個問題/或修復它?

嘗試只search在你的線上使用resolv.conf

search mycompany.local devnet.mycompany.nl

其次,您的digusing only測試jira失敗,這是正常行為!dig不會使用resolv.conf.

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