我的/etc/resolv.conf
包含一行search
如下的内容:
search a.local b.local c.local
该ping
命令运行正常:
$ ping some-server
PING some-server.b.local (10.20.30.40) 56(84) bytes of data.
64 bytes from 10.20.30.40 (10.20.30.40): icmp_seq=1 ttl=58 time=47.8 ms
但是,如果没有 FQDN,则以下nslookup
(或host
) 命令不起作用:
$ nslookup some-server
;; Got SERVFAIL reply from 10.100.0.200, trying next server
;; Got SERVFAIL reply from 10.100.0.201, trying next server
Server: 127.0.0.53
Address: 127.0.0.53#53
** server can't find some-server: SERVFAIL
$ nslookup some-server.b.local
Server: 10.100.0.200
Address: 10.100.0.200#53
Non-authoritative answer:
Name: some-server.b.local
Address: 10.20.30.40
我该如何修复 nslookup 以便能够正确地与我的搜索域配合使用?
答案1
要确保您具有正确的 DNS 设置,请尝试执行以下操作:
sudo nano /etc/resolvconf/resolv.conf.d/base
然后粘贴以下内容:
# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.
nameserver 8.8.8.8
nameserver 8.8.4.4
然后退出并保存文件
sudo resolvconf -u #updates the resolve file from the file we made above.
cat /etc/resolv.conf # prints the contents of the resolv file
它应该会显示我们保存在那里的文本。之后尝试之前失败的 nslookup,希望它现在能正常工作。