我在 Virtual Box 上安装了 archlinux,我使用 NetworkManager 来处理我的连接。 在我尝试从使用 NetworkManager for dns 切换为“未绑定(bind)”之后,我似乎无法让它们一起运行。我按照 https://wiki.archlinux.org/index.php/unbound 上的 unbound 指南进行操作
我的/etc/unbound/unbound.conf 看起来像:
include: "/etc/unbound/resolvconf.conf"
server:
use-syslog: yes
do-daemonize: no
username: "unbound"
directory: "/etc/unbound"
trust-anchor-file: trusted-key.key
private-domain: "intranet"
private-domain: "internal"
private-domain: "private"
private-domain: "corp"
private-domain: "home"
private-domain: "lan"
unblock-lan-zones: yes
insecure-lan-zones: yes
domain-insecure: "intranet"
domain-insecure: "internal"
domain-insecure: "private"
domain-insecure: "corp"
domain-insecure: "home"
domain-insecure: "lan"
root-hints: root.hints
我的/etc/resolvconf.conf 看起来像:
# Configuration for resolvconf(8)
# See resolvconf.conf(5) for details
resolv_conf=/etc/resolv.conf:
# If you run a local name server, you should uncomment the below line and
# configure your subscribers configuration files below.
name_servers="::1 127.0.0.1"
private_interfaces="*"
# Write out unbound configuration file
unbound_conf=/etc/unbound/resolvconf.conf
使用 resolvconf -u 生成新的 resolv.conf 后,/etc/resolv.conf 如下所示:
# Generated by resolvconf
nameserver ::1
nameserver 127.0.0.1
检查 systemctl status unbound 后,它表示 unbound 处于事件状态并正在运行。 重新启动后,NetworkManager 仍在生成 resolv.conf 并通过 resolvconf -u 命令重置该 resolv.conf。因此,经过一番搜索后,我发现我应该在/etc/NetworkManager/NetworkManager.conf 中设置 dns=unbound ,从一开始只需在顶部添加注释行,并且我添加了 [main] 和 dns=unbound 字段:
# Configuration file for NetworkManager.
# See "man 5 NetworkManager.conf" for details.
[main]
dns=unbound
现在重新启动后/etc/resolv.conf 不会被网络管理器重置,但我没有任何互联网连接和 systemctl 状态 NetworkManager 说启动失败:
NetworkManager.service: Main process exited, code=exited, status=1/FAILURE
NetworkManager.service: Failed with result 'exit-code'.
Failed to start Network Manager.
NetworkManager.service: Service RestartSec=100ms expired, scheduling restart.
我不太明白问题出在哪里,据我了解,使用“unbound”作为 NetworkManager 的 dns 应该相当简单。
最佳答案
我似乎通过不将 networkmanager.conf 设置为
解决了这个问题[main]
dns=unbound
而是将其设置为:
[main]
dns=none
现在重新启动后,resolv.conf 不会被网络管理器重置,而且我也有互联网连接。
关于linux - 未绑定(bind) DNS 的 NetworkManager,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54503512/