首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使dnsmasq不改变resolv.conf

使dnsmasq不改变resolv.conf
EN

Unix & Linux用户
提问于 2017-02-24 20:35:46
回答 4查看 11.2K关注 0票数 5

每次我(重新)启动dnsmasq时,它都将/etc/resolv.conf替换为nameserver 127.0.0.1 ...

但是,maschine不需要使用本地DNS服务。(请不要问为什么,整个环境就像.)

我怎样才能真正防止/etc/resolv.conf接触?

删除resolvconfchattr +i /etc/resolv.conf都不是一种选择。

EN

回答 4

Unix & Linux用户

发布于 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并注释掉这两行

代码语言:javascript
复制
#ExecStartPost=/etc/init.d/dnsmasq systemd-start-resolvconf
#ExecStop=/etc/init.d/dnsmasq systemd-stop-resolvconf

exec sudo systemctl daemon-reload

之后,您可以启动dnsmasq,并且/etc/ can文件不会被dnsmasq更改。

票数 4
EN

Unix & Linux用户

发布于 2017-02-24 21:07:11

您可以让dnsmasq使用不同的resolv.conf文件,所以当/etc/resolv.conf指向127.0.0.1时,dnsmasq实际上只使用其他resolv.conf文件,而不使用/etc/resolv.conf

将以下行添加到dnsmasq.conf文件中:

代码语言:javascript
复制
resolv-file=/etc/dnsmasq.d/dnsmasq-resolv.conf

然后创建文件/etc/dnsmasq.d/dnsmasq-resolv.conf,如下所示:

代码语言:javascript
复制
nameserver 208.67.222.222
nameserver 208.67.220.220
票数 2
EN

Unix & Linux用户

发布于 2017-02-25 13:19:54

  1. systemctl disable resolvconf.service
  2. systemctl stop resolvconf.service
  3. rm -f /etc/resolv.conf
  4. echo 'nameserver 8.8.8.8' > /etc/resolv.conf # or any other IP you want to use as DNS server
  5. systemctl restart dnsmasq.service # just for testing
  6. cat /etc/resolv.conf # just to verify

这台机器无法通过DHCP获得DNS服务器地址(Es),但它解决了这个问题。

票数 2
EN
页面原文内容由Unix & Linux提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://unix.stackexchange.com/questions/347425

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档