我想试试Google公共DNS.为此,我需要更改名称服务器地址.我知道它位于文件/etc/resolv.conf中,但每当我启动网络管理器时,它会使用DHCP获取的内容覆盖该文件中的值.
我怎么告诉它不要这样做?我查看了GUI,但我只能找到添加更多IP地址的选项.
下面是奖杯:)
解决方法:
方法#1
找到NetworkManager配置文件并添加/修改以下条目(在CentOS5中,它位于/etc/NetworkManager/nm-system-settings.conf或/ etc / NetworkManager / system-connections /)并编辑您的DSL连接文件:
[ipv4]
method=auto
dns=8.8.8.8;4.2.2.2;
ignore-auto-dns=true
注意: – 如果[ipv4]不起作用,请尝试[ppp]
方法#2
您可以更改/etc/resolv.conf的权限,以便其他服务无法写入,也可以使用chattr.
方法#3
在/etc/Networkmanager/dispatcher.d/中创建如下所述的脚本,并且不要忘记使其可执行:
#!/bin/bash
#
# Override /etc/resolv.conf and tell
# NetworkManagerDispatcher to go pluck itself.
#
# scripts in the /etc/NetworkManager/dispatcher.d/ directory
# are called alphabetically and are passed two parameters:
# $1 is the interface name, and $2 is "up" or "down" as the
# case may be.
# Here, no matter what interface or state, override the
# created resolver config with my config.
cp -f /etc/resolv.conf.myDNSoverride /etc/resolv.conf
/etc/resolv.conf.myDNSoverride的条目
nameserver 8.8.8.8