我希望为我的 dns 名称服务器设置更高的优先级,或者覆盖 dhcp 服务器设置的优先级。无论我采用哪种方法,nslookup
都不会显示正确的 dns 名称服务器。
请参阅下面的片段。
$ cat /etc/*release* | grep -i dist
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04 LTS"
解析配置:
$ cat /etc/resolvconf/resolv.conf.d/base
nameserver 208.67.222.222
nameserver 208.67.220.220
$ sudo resolvconf --enable-updates
$ sudo resolvconf -u
$ nslookup
> server
Default server: 127.0.1.1
Address: 127.0.1.1#53
DHCP:
$ tail -n 1 /etc/dhcp/dhclient.conf
supersede domain-name-servers 208.67.222.222, 208.67.220.220;
$ sudo service networking restart
$ nslookup
> server
Default server: 127.0.1.1
Address: 127.0.1.1#53
如何才能做到这一点?
答案1
向 resolvconf 配置文件添加标题。创建或编辑文件“/etc/resolvconf/resolv.conf.d/head“。添加您的偏好。
/etc/resolvconf/resolv.conf.d/head:
# 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
nameserver 8.8.8.8
search [yourpreference.com]
重新启动您的网络服务,重新启动是重新启动它的最可靠方法。
答案2
看https://askubuntu.com/a/63163/267945- 更好的解决方案:
如果您想要覆盖或附加 DHCP 服务器建议的名称服务器,您可以在中进行配置
/etc/dhcp/dhclient.conf
,例如:interface "eth0" { prepend domain-name-servers 10.0.0.2; }