Make dnsmasq not altering resolv.conf

dnsdnsmasqresolv.confresolvconf

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

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.

Best Answer

You can have dnsmasq use a different resolv.conf file, so when /etc/resolv.conf points to 127.0.0.1, 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:

resolv-file=/etc/dnsmasq.d/dnsmasq-resolv.conf

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

nameserver 208.67.222.222
nameserver 208.67.220.220
Related Question