I am on Ubuntu 18.04 using the netplan configuration which renders using NetworkManager:

# Let NetworkManager manage all devices on this system
  version: 2
  renderer: NetworkManager

Every time I restart, the following output is automatically generated and written to /etc/resolv.conf, breaking my dnsmasq configuration in that I can no longer resolve domains on the internet:

# Generated by NetworkManager

I can fix this manually by simply commenting out the nameserver line in /etc/resolv.conf. Before I write a script to perform this commenting out every reboot, I should understand what's going on.

This is my simple /etc/dnsmasq.conf:





1) Why is this being written by NetworkManager every reboot?

2) Why is it breaking dnsmasq anyway because the strict-order server settings should forward all other requests to google's DNS server? When dnsmasq is running, does the system look in resolv.conf first or after dnsmasq.conf?

  • 1
    The problem is due to a couple of problems. Understand that DNS in 18.xx is kinda screwball. Edit your question with the output from ls -al /etc/resolv.conf and ps auxc | grep dns and ps auxc | grep resolv and cat /run/resolvconf/resolv.conf and cat /run/systemd/resolve/resolv.conf. Are you using dnsmasq for DNS, or DHCP? Did you install it, or did it come over from an upgrade? – heynnema Feb 6 at 15:51
  • I totally don't understand what's going on - why does dnsmasq only work when the contents of /etc/resolv.conf are empty if systemd-resolvd is disabled? – JSStuball Feb 7 at 4:14
  • If you respond to my earlier comment, I'll have some info to go on. Also show me cat /etc/NetworkManager/NetworkManager.conf. – heynnema Feb 7 at 4:41

Same problem with dnsmasq:

  1. Edit /etc/NetworkManager/NetworkManager.confand after [Main] add or change to dns=none. Save the file.
  2. Execute systemctl restart NetworkManager.service (please note uppercase and lowercase).
  3. Edit /etc/resolv.conf with your values. Save the file.

Optional testing: reboot and confirm.

Hope be useful, thanks for your attention.

  • OMG thatnks a ton! NetworkManager and dnsmasq have been a thorn in my side for the last week – MBulava Jun 14 at 1:06

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.