indexad

linux DNS修改后不生效


DNS修改后,系统重启之后就木有了,写在/etc/resolv.conf文件中的,

方法一、修改/etc/network/interfaces
dns-nameservers 111.111.111.111

方法二、修改/etc/resolvconf/resolv.conf.d/base文件,该文件默认是空的,在里面写入:
nameserver 1.1.1.1
nameserver 2.2.2.2
修改完之后保存,然后执行resolvconf -u
然后,你会发现/etc/resolv.conf文件中多了几行,这几行是resolve程序自动写入的:
#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 1.1.1.1
nameserver 2.2.2.2

方法三、修改/etc/resolv.conf

设置DNS:
Ubuntu设置DNS,只要将DNS地址写入/ect/resolv.conf文件即可,
但在12.04 desktop版中,重启系统之后,静态IP设置生效,但无法链接外网,
/etc/resole.conf文件的DNS地址也覆盖掉了。
解决办法,在/etc/resolvconf/resolv.conf.d/目录下创建tail文件,写入
nameserver 202.96.134.133
nameserver 202.96.128.68
然后重启,DNS生效