Every time I (re)start dnsmasq it replaces /etc/resolv.conf with nameserver ....

However that maschine has not to use the local DNS service. (Please don't ask why, the whole environment is like it is...)

How do I actually prevent dnsmasq from touching /etc/resolv.conf?

Neither removing resolvconf nor chattr +i /etc/resolv.conf is an option.


You can have dnsmasq use a different resolv.conf file, so when /etc/resolv.conf points to, dnsmasq will actually just use the other resolv.conf file and leave /etc/resolv.conf alone.

Add the following line to your dnsmasq.conf file:


And then create the file /etc/dnsmasq.d/dnsmasq-resolv.conf to look something like this:

| improve this answer | |
  • Unfortunately this doesn't help. – Al Klimov Feb 24 '17 at 22:34
  • So, it looks like I missed something. I'm guessing it's related to your DNS configuration, and that you have a "real" DNS server listening on, other than dnsmasq, which is why /etc/resolv.conf cannot point to (as you said you don't want the local machine using the local DNS)? Would the no-resolv option for dnsmasq help? Have I completely missed the crux of your question? – airhuff Feb 24 '17 at 23:07
  • The maschine runs no dns server other than dnsmasq. No, no-resolv doesn't help. – Al Klimov Feb 25 '17 at 9:47
  1. systemctl disable resolvconf.service
  2. systemctl stop resolvconf.service
  3. rm -f /etc/resolv.conf
  4. echo 'nameserver' > /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

The machine won't be able to get the DNS server address(es) via DHCP, but it solves the problem.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.