Ubuntu 12.10 DNS 配备
Ubuntu 12.10 DNS 配置
不要对这个视若无睹。以为即便你当时改对了,网络服务一重启,又不行了。
首先不推荐修改/etc/resolv.conf或者修改/etc/resolvconf/resolv.conf.d/目录下的head,base文件,添加tail文件的方法也不赞成。
因为resolv.conf和head文件中都有提醒文字:
cat /etc/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
cat /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
不要对这个视若无睹。以为即便你当时改对了,网络服务一重启,又不行了。
用man resolvconf命令查看文档,可以看到一段提醒注意的文字:
N.B.: On a machine where resolvconf has just been or is about to be installed and which previously relied on a static /etc/resolv.conf file, the nameserver informa‐ tion in that static file should be migrated to the appropriate iface stanza(s) in interfaces(5).证明了的确不推荐修改上面的文件,而建议修改/etc/network/interfaces文件。下面是个正确的例子:
# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 iface eth0 inet static address 10.112.18.106 network 10.112.18.0 netmask 255.255.255.0 broadcast 10.112.18.255 gateway 10.112.18.254 dns-nameservers 10.112.18.1
就是最后一行dns-nameservers,可以添加多个,用空格分开
上面我用的是静态IP地址,很多时候需要使用DHCP动态分配IP, 这个时候dns-nameservers仍然能够使用,不过优先级比DHCP提供的dns要低。可以改变这个优先级,通过修改/etc/resolvconf/interface-order配置文件。
现在用nslookup来查找dns,一切正常:
nslookup google.com Server: 10.112.18.1 Address: 10.112.18.1#53 Non-authoritative answer: Name: google.com Address: 74.125.224.229 Name: google.com Address: 74.125.224.224 Name: google.com Address: 74.125.224.238 Name: google.com Address: 74.125.224.230 Name: google.com Address: 74.125.224.232 Name: google.com Address: 74.125.224.227 Name: google.com Address: 74.125.224.233 Name: google.com Address: 74.125.224.231 Name: google.com Address: 74.125.224.225 Name: google.com Address: 74.125.224.226 Name: google.com Address: 74.125.224.228