Al *_*mov 6 dns dnsmasq resolv.conf
每次我(重新)启动 dnsmasq 时,它都会替换/etc/resolv.conf
为nameserver 127.0.0.1 ...
.
然而,该机器不必使用本地 DNS 服务。(请不要问为什么,整个环境就是这样……)
我如何真正阻止 dnsmasq 接触/etc/resolv.conf
?
删除resolvconf
也不chattr +i /etc/resolv.conf
是一个选项。
dnsmasq 本身不会改变 resolv.conf 如果您有配置文件并通过dnsmasq -d -C <yourconfig>
您看到的手动启动它。
此行为来自 debian 上的 systemd 单元,也可能来自 ubuntu 系统以及其他发行版上的 systemd 单元。
通过停止 dnsmasq sudo systemctl stop dnsmasq
(因为否则更改的 /etc/resolv.conf 将不会恢复)编辑/etc/systemd/system/multi-user.target.wants/dnsmasq.service
并注释掉这两行
#ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
#ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf
Run Code Online (Sandbox Code Playgroud)
执行sudo systemctl daemon-reload
之后你可以启动 dnsmasq 并且你的 /etc/resolv.conf 文件不会被 dnsmasq 更改
您可以dnsmasq
使用不同的resolv.conf
文件,因此当/etc/resolv.conf
指向 127.0.0.1 时,dnsmasq
实际上只会使用其他resolv.conf
文件并保持/etc/resolv.conf
不变。
将以下行添加到您的dnsmasq.conf
文件中:
resolv-file=/etc/dnsmasq.d/dnsmasq-resolv.conf
Run Code Online (Sandbox Code Playgroud)
然后创建文件,/etc/dnsmasq.d/dnsmasq-resolv.conf
如下所示:
nameserver 208.67.222.222
nameserver 208.67.220.220
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
12424 次 |
最近记录: |