0

not able to find a workaround for the dnsmasq to not make changes in /etc/resolv.conf file.

editing the init.d/dnsmasq file is not a full option as not on all ubuntu version dnsmasq runs through init.d

hope you can help !

  • Found an interesting file /etc/resolvconf/update.d/dnsmasq . As for me , I've set my dns through /etc/dhcp/dhclient.conf, now no matter what , nm-tool reports that i use those dns servers that i specified. Want me to post it as an answer ? – Sergiy Kolodyazhnyy Apr 09 '15 at 08:50
  • if you could describe a bit more throughout i would be grateful.

    as an answer would be great !

    – Vitalik Jimbei Apr 09 '15 at 09:32
  • i came to find that on those versions of dnsmasq without the daemon in init.d , there is no such file -- /etc/resolvconf/update.d/dnsmasq

    this is a file the daemon in init.d generates.

    i am looking for a workaround in these specific folders which remain no matter dnsmasq and ubuntu version -- /etc/dnsmasq.conf or or /etc/default/dnsmasq

    – Vitalik Jimbei Apr 09 '15 at 09:38

3 Answers3

1

Problem is because Network Manager uses dynamically your /etc/resolv.conf with dnsmasq

Solution for you to change way how to resolve names. Try following

In /etc/NetworkManager/NetworkManager.conf comment out the dns=dnsmasq

sudo nano /etc/NetworkManager/NetworkManager.conf

 [main]
plugins=ifupdown,keyfile,ofono
#dns=dnsmasq

no-auto-default=00:22:64:4E:6F:70,

[ifupdown]
managed=fals

and restart the NM service

sudo restart network-manager

With this /etc/resolv.conf is no longer dependant on resolvconf package and is updated based on the DNS entries of each connection in the Network Manager

Also you can add nameserver in /etc/resolv.conf. If you not set dns in NM per connection this will be used

sudo nano /etc/resolv.conf

nameserver 8.8.4.4
nameserver 8.8.8.8

Edit One

Stop the service resolvconf

sudo service resolvconf stop

disable it

update-rc.d resolvconf disable

disable resolvconf to overwrite resolv.conf

create /etc/init/resolvconf.override with single line manual

echo 'manual' | sudo tee /etc/init/resolvconf.override

remove symbolic link /etc/resolv.conf

rm /etc/resolv.conf

create resolv.conf with static dns entry

echo "namserver x.x.x.x." > /etc/resolv.conf
2707974
  • 10,553
  • 6
  • 33
  • 45
  • i don't have such file

    /etc/NetworkManager/NetworkManager.conf

    – Vitalik Jimbei Apr 09 '15 at 08:16
  • should i install network manager ?? – Vitalik Jimbei Apr 09 '15 at 08:16
  • network manager does not help. commenting out the conf file of network manager file does nothing for me.

    the init.d of dnsmasq still edits the resolv.conf file and uses the echo-ed nameserver and the dns servers of the IPv6 protocol

    – Vitalik Jimbei Apr 09 '15 at 08:35
  • You have my edit one in answer – 2707974 Apr 09 '15 at 08:38
  • is there maybe an option i can add in /etc/dnsmasq.conf or /etc/dnsmasq.d or /etc/default/dnsmasq than does the same thing ? – Vitalik Jimbei Apr 09 '15 at 08:51
  • No, you can not create sonething.config and read DNS config from there. Resolv lib look /etc/host.conf for order and /etc/hosts for local host Default order is order hosts,bind If you dont have entry for specific address in /etc/hosts PC will ask bind->/etc/resolv.conf. – 2707974 Apr 09 '15 at 10:09
0

You can try setting chattr to immutable.

chattr +i /path/to/filename

To remove immutable to allow changes again change the flag on the file.

chattr -i /path/to/filename
Cory C
  • 89
0

This may or may not solve your problem, but I was having a similar problem where dnsmasq (well, actually the combo of dnsmasq and resolvconf) was rewriting my /etc/resolv.conf file and ignoring the dns-nameservers options that I set in /etc/network/interfaces.

What the problem turned out to be was that resolvconf would call dnsmasq to update the nameserver entries in resolv.conf, and then it seems that it would quit after that.

I got it to keep the dns-nameservers entries from /etc/network/interfaces by moving my interface (p+([0-9])p+([0-9])?(_+([0-9]))* in my case) to before the "lo.dnsmasq" entry in /etc/resolvconf/interface-order. So now instead of getting "nameserver 127.0.0.1" as the first, last, and only nameserver entry in /etc/resolv.conf, I get

nameserver <ipaddr.frometc.network.interfaces> nameserver <another.frometc.network.interfaces> nameserver 127.0.0.1 search <domains from /etc/network/interfaces>

So now it seems that resolvconf runs, checks the interface order, and adds the entries from /etc/network/interfaces corresponding to the entries above "lo.dnsmasq", then calls a dnsmasq process to add those to the file, but that somehow works not quite right and it ignores any interfaces after that.

When I was trying to figure this out I searched, to no avail, about why dnsmasq was ignoring /etc/network/interfaces. (I was certain that dnsmasq was involved because this happened shortly after I installed dnsmasq) I am not sure if that solves your problem, but to me it seemed a little bit cleaner than just removing resolvconf.

  • This got me half-way to a solution however my dns-nameservers directive in my /etc/network/interfaces for a static ip bridge seemed to be completely ignored for reasons I don't know. I was only able to get going after commenting out dns-nameservers and adding something like this: post-up echo "nameserver 8.8.8.8" > /var/run/resolvconf/interfaces/br0MANUAL.inet && /usr/sbin/resolvconf -u. I'm not entirely happy with these two kludges (interface-order edits and the post-up edit) and would certainly entertain cleaner alternatives. – acker9 Apr 30 '21 at 18:39