Waj*_*hat 2 dns centos networkmanager
我在 /etc/resolv.conf 中更改了名称服务器,但是当我在 CentOS 中连接 vpn 时,网络管理器将我以前的 DNS 推送回 /etc/resolv.conf。
我不希望网络管理器将从 DHCP 收到的 DNS 服务器添加到我的 /etc/resolv.conf。
有什么解决办法吗?
防止在 Linux 中更新文件的“蛮力”方法可能是使用chattr,例如您可以执行以下操作:
chattr +i /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)
要删除i - Immutable属性以便您可以再次修改文件,请运行:
chattr -i /etc/resolv.conf
Run Code Online (Sandbox Code Playgroud)
另一种方法可能是配置/etc/NetworkManager/NetworkManager.conf为不修改 DNS:
[main]
dns=none
Run Code Online (Sandbox Code Playgroud)
来自男人:
dns
Set the DNS (resolv.conf) processing mode.
default: The default if the key is not specified. NetworkManager will update
resolv.conf to reflect the nameservers provided by currently active connections.
dnsmasq: NetworkManager will run dnsmasq as a local caching nameserver, using a "split
DNS" configuration if you are connected to a VPN, and then update resolv.conf to point
to the local nameserver.
none: NetworkManager will not modify resolv.conf.
Run Code Online (Sandbox Code Playgroud)
小智 6
设置dns=none仍然可能允许网络管理器破坏东西 - 如果在 ifcfg 文件中还指定了DOMAIN ,NM 仍然会写入该文件,但会跳过任何 dns:es 而建议在 [main] 部分下设置以下内容:
rc-manager=unmanaged
Run Code Online (Sandbox Code Playgroud)
/etc/resolv.conf根据文档,这告诉网络管理器根本不要触摸