在运行Ubuntu 16.04.2 LTS的RPi上,我的发现如下:
注意:我卸载了NetworkManager并只剩下resolvconf来完成它的工作。(这是一台固定服务器,因此在网络方面不会有太大变化。)
如果仅在一个接口(主接口,有线接口)上有dns-search和dns-nameserver行,但在重启时没有其他接口(wlan0),则大约在我的/etc/resolv.conf文件中有95%的时间是空的。
例如,当我的接口文件如下所示:
# The primary network interface
auto enxb827ebbfedcf
iface enxb827ebbfedcf inet static
address 192.168.1.16
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-search summer.co.uk summer.vpn
dns-nameserver 192.168.1.16
dns-nameserver 192.168.1.1
# end stanza with clear line+
# The loopback network interface
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 192.168.1.17
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
然后,在重新启动后,我的resolv.conf将如下所示:
# 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
但是,在一两次重启后,我注意到它DID具有我想要的功能,例如
# 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 192.168.1.16
nameserver 192.168.1.1
search summer.co.uk summer.vpn
解决方案
当我为两个接口(有线和wlan0)提供dns-search和dns-nameserver线时,每次重新启动都正常(到目前为止)
即以下接口文件为我工作:
# The primary network interface
auto enxb827ebbfedcf
iface enxb827ebbfedcf inet static
address 192.168.1.16
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-search summer.co.uk summer.vpn
dns-nameserver 192.168.1.16
dns-nameserver 192.168.1.1
# end stanza with clear line+
# The loopback network interface
auto lo
iface lo inet loopback
auto wlan0
iface wlan0 inet static
address 192.168.1.17
netmask 255.255.255.0
network 192.168.1.0
broadcast 192.168.1.255
gateway 192.168.1.1
dns-search summer.co.uk summer.vpn
dns-nameserver 192.168.1.16
dns-nameserver 192.168.1.1
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
并在每次重启后给我以下正确的resolv.conf(到目前为止)
# 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 192.168.1.16
nameserver 192.168.1.1
search summer.co.uk summer.vpn
我认为这个重复的配置是正常的,如果有些多余的话。
结论:如果接口(lo0除外)缺少dns-search和dns-nameserver信息,则resolvconf不会在您的resolv.conf文件中放置任何内容。(就好像ifup第二次执行wlan0接口,ifup擦除了resolv.conf之类。)
我不确定这是否是错误,但是我感到不对。