NetworkManager writing to resolv.conf every reboot, breaking dnsmasq?

6,619

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.

Share:
6,619

Related videos on Youtube

sphere
Author by

sphere

Updated on September 18, 2022

Comments

  • sphere
    sphere over 1 year

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

    # Let NetworkManager manage all devices on this system
    network:
      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
    nameserver 127.0.0.53
    

    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:

    port=53
    domain-needed
    bogus-priv
    strict-order
    
    server=/mydomain.net/10.0.0.2
    server=/#/8.8.8.8
    
    listen-address=127.0.0.1
    
    bind-interfaces 
    

    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?

    • Boris Hamanov
      Boris Hamanov about 5 years
      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?
    • sphere
      sphere about 5 years
      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?
    • Boris Hamanov
      Boris Hamanov about 5 years
      If you respond to my earlier comment, I'll have some info to go on. Also show me cat /etc/NetworkManager/NetworkManager.conf.
  • MBulava
    MBulava almost 5 years
    OMG thatnks a ton! NetworkManager and dnsmasq have been a thorn in my side for the last week