使用 resolvconf、dnsmasq 和 networkmanager 添加其他名称服务器

使用 resolvconf、dnsmasq 和 networkmanager 添加其他名称服务器

我正在运行resolvconf,接口和连接由(nm)dnsmasq管理。NetworkManager

dnsmasq应该缓存 dns 条目,并使用通过 DHCP 手动配置的上游服务器。

问题是 dnsmasq 最终似乎使用了配置的上游仅有的via nm(使用 DHCP) - 无法弄清楚如何添加手动配置的后备(或就此而言的主要)。

$ cat NetworkManager.conf 
[main]
plugins=ifupdown,keyfile
rc-manager=resolvconf
# tried also this instead of 'rc-manager': dns=dnsmasq

[ifupdown]
managed=true


$ cat /run/dnsmasq/resolv.conf
nameserver ns-via-dhcp-1
nameserver ns-via-dhcp-2
nameserver ns-via-dhcp-3
nameserver ns-via-dhcp-4
nameserver 127.0.0.1


$ cat /run/NetworkManager/resolv.conf   (think this isn't used anymore as resolvconf pkg is installed?)
# Generated by NetworkManager
search internal.company.domain.co.uk
nameserver ns-via-dhcp-1
nameserver ns-via-dhcp-2
nameserver ns-via-dhcp-3
# NOTE: the libc resolver may not support more than 3 nameservers.
# The nameservers listed below may not be recognized.
nameserver ns-via-dhcp-4


$ cat /run/resolvconf/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
nameserver 1.1.1.1
nameserver 127.0.0.1
search internal.company.domain.co.uk


$ 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
nameserver 1.1.1.1

/etc/resolv.conf链接到/etc/resolvconf/run/resolv.conf,其内容与 相同/run/resolvconf/resolv.conf

注意1.1.1.1是我试图添加的自定义名称服务器,但似乎dnsmasq没有使用它。现在每次查找任何域都需要 2 秒,这表明没有缓存任何内容。

dnsmasq处理参数:

/usr/sbin/dnsmasq -x /run/dnsmasq/dnsmasq.pid -u dnsmasq -r /run/dnsmasq/resolv.conf -7 /etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new --local-service --trust-anchor=.,20326,8,2,e06d44b80b8f1d39a95c0b0d7c65d08458e880409bbc683457104237c7f8ec8d

还尝试添加server=1.1.1.1到 dnsmasq 配置,但这也不起作用。有什么建议么?

答案1

使用以下行: rc-manager=resolvconf

您的网络管理员正在诉诸使用 resolvconf,这将从您的网络适配器中提取设置,或者,如果您不想更改网络适配器,您可以编辑 /etc/resolvconf/resolv.conf.d/base 文件并添加行:名称服务器 1.1.1.1

更详细的答案请参见这里的答案 https://unix.stackexchange.com/a/128223/191614

相关内容