每次我(重新)启动dnsmasq时,它都将/etc/resolv.conf替换为nameserver 127.0.0.1 ...。
但是,maschine不需要使用本地DNS服务。(请不要问为什么,整个环境就像.)
我怎样才能真正防止/etc/resolv.conf接触?
删除resolvconf或chattr +i /etc/resolv.conf都不是一种选择。
发布于 2020-12-10 18:00:19
dnsmasq本身并没有改变resolv.conf,如果您有您的配置文件并通过dnsmasq -d -C <yourconfig>手动启动它,您将看到这一点。
这种行为来自debian上的systemd单元,可能在ubuntu系统上,或者在其他发行版上。
通过sudo systemctl stop dnsmasq停止dnsmasq (因为否则更改/etc/ both不会恢复),编辑/etc/systemd/system/multi-user.target.wants/dnsmasq.service并注释掉这两行
#ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
#ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconfexec sudo systemctl daemon-reload
之后,您可以启动dnsmasq,并且/etc/ can文件不会被dnsmasq更改。
发布于 2017-02-24 21:07:11
您可以让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然后创建文件/etc/dnsmasq.d/dnsmasq-resolv.conf,如下所示:
nameserver 208.67.222.222
nameserver 208.67.220.220发布于 2017-02-25 13:19:54
systemctl disable resolvconf.servicesystemctl stop resolvconf.servicerm -f /etc/resolv.confecho 'nameserver 8.8.8.8' > /etc/resolv.conf # or any other IP you want to use as DNS serversystemctl restart dnsmasq.service # just for testingcat /etc/resolv.conf # just to verify这台机器无法通过DHCP获得DNS服务器地址(Es),但它解决了这个问题。
https://unix.stackexchange.com/questions/347425
复制相似问题