0

My NetworkManager is not writing to /var/run/networkmanager/resolv.conf and NetworkManager not populating resolv.conf is not the answer to my situation, because I don't use resolvconf. More details below:

I switched managing my ethernet from /etc/network/interfaces to NetworkManager, which somehow never writes to /var/run/networkmanager/resolv.conf:

$ nmcli d  
DEVICE  TYPE      STATE      CONNECTION  
eth0    ethernet  connected  Wired connection 1
lo      loopback  unmanaged  --          

$ ls /var/run/NetworkManager/resolv.conf
ls: cannot access '/var/run/NetworkManager/resolv.conf': No such file or directory

$ ls /var/run/nm-dns-dnsmasq.conf
ls: cannot access '/var/run/nm-dns-dnsmasq.conf': No such file or directory

That never bothered me when I'm using /etc/network/interfaces, but now that I'm using NetworkManager, I need it to update my resolv.conf.

Here is my NetworkManager.conf:

cat /etc/NetworkManager/NetworkManager.conf
[main]
plugins=ifupdown,keyfile
dns=dnsmasq

[ifupdown]
managed=false

[device]
wifi.scan-rand-mac-address=no

Some answers say I should have dns=dnsmasq in there, but some say I should not. All in all, I'm still confused how to have NetworkManager updating /var/run/networkmanager/resolv.conf.

Update, further info:

$ resolvectl status | grep DNS
-su: resolvectl: command not found

$ dpkg -l '*dns*' | grep 'ii *dns'
ii  dns-root-data  2018013001   all          DNS root data including root zone
ii  dnsmasq        2.79-1       all          Small caching DNS proxy and DHCP/
ii  dnsmasq-base   2.79-1       amd64        Small caching DNS proxy and DHCP/
ii  dnsutils       1:9.11.3+dfs amd64        Clients provided with BIND

$ dpkg -l '*resolv*' | grep ii || echo no resolvconf
no resolvconf

$ ls -al /etc/resolv.conf
-rw-r--r-- 1 root root 79 2019-03-03 18:42 /etc/resolv.conf

$ host 8.8.8.8 
8.8.8.8.in-addr.arpa domain name pointer google-public-dns-a.google.com.

$ host www.ebay.com
www.ebay.com is an alias for slot9428.ebay.com.edgekey.net.
slot9428.ebay.com.edgekey.net is an alias for e9428.b.akamaiedge.net.
e9428.b.akamaiedge.net has address 104.93.181.25

$ lsb_release -a 
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 18.04.1 LTS
Release:        18.04
Codename:       bionic

Update2.

  • This is not a vanilla Ubuntu installation, but my customized installation from fresh (not an upgrade from previous version). I remove resolvconf myself, because I was using /etc/network/interfaces, and didn't want my /etc/resolv.conf to be changing all the time. Maybe that's the culprit and NetworkManager can't work without resolvconf?
  • My full intention is to "Replace systemd-resolved with dnsmasq" (which I practiced using 18.04 LiveCD, which has the resolvconf), and use it for my LAN DNS server. Em, maybe in that case I don't need NetworkManager changing my /etc/resolv.conf all the time.

Anyway, here are the info for further investigation:

$ dpkg -l '*resolv*'
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name           Version      Architecture Description
+++-==============-============-============-=================================
un  resolvconf     <none>       <none>       (no description available)

$ cat /run/resolvconf/resolv.conf
cat: /run/resolvconf/resolv.conf: No such file or directory

$ cat /run/systemd/resolve/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
. . . 
nameserver 64.71.255.204
nameserver 64.71.255.198
search hitronhub.home

$ cat /etc/netplan/*.yaml
# Let NetworkManager manage all devices on this system
network:
  version: 2
  renderer: NetworkManager
  ethernets:
    eth0:
      addresses: [192.168.0.11/24, 192.168.0.10/24]
      gateway4: 192.168.0.1

$ ps auxc | grep resolv
systemd+ 23890  0.0  0.0  70608  1520 ?        Ss   Mar01   0:00 systemd-resolve

$ sudo lsof -i tcp:53
COMMAND     PID            USER   FD   TYPE   DEVICE SIZE/OFF NODE NAME
systemd-r 23890 systemd-resolve   13u  IPv4 47127798      0t0  TCP 127.0.0.53:domain (LISTEN)
dnsmasq   29822         dnsmasq    5u  IPv4 47935969      0t0  TCP 192.168.0.10:domain (LISTEN)
dnsmasq   29822         dnsmasq    7u  IPv4 47935971      0t0  TCP 192.168.0.11:domain (LISTEN)
dnsmasq   29822         dnsmasq    9u  IPv4 47935973      0t0  TCP localhost.myhost.org:domain (LISTEN)
dnsmasq   29822         dnsmasq   11u  IPv6 47935975      0t0  TCP [fe80::xxxx]:domain (LISTEN)
dnsmasq   29822         dnsmasq   13u  IPv6 47935977      0t0  TCP [2607:fea8:xxxx]:domain (LISTEN)
dnsmasq   29822         dnsmasq   15u  IPv6 47935979      0t0  TCP [fd00:xxxx]:domain (LISTEN)
dnsmasq   29822         dnsmasq   17u  IPv6 47935981      0t0  TCP ip6-localhost:domain (LISTEN)
  • I am not surprised that a 2012 post is no longer effective. Please edit your question to add the result of: resolvectl status | grep DNS Welcome to Ask Ubuntu. – chili555 Mar 4 at 0:00
  • What version Ubuntu? Edit your question and show me dpkg -l *dns* | grep ii and dpkg -l *resolv* | grep ii and ls -al /etc/resolv.conf and host 8.8.8.8 and host www.ebay.com. Report back to @heynnema – heynnema Mar 4 at 2:40
  • Thanks @chili555, I got resolvectl: command not found for that. – xpt Mar 4 at 4:38
  • Something is wrong here. Is your 18.04 an upgrade, or a clean install? Show me cat /run/resolvconf/resolv.conf and cat /run/systemd/resolve/resolv.conf and cat /etc/netplan/*.yaml and ps auxc | grep resolv. Have you made any modifications to any network software here? Uninstalled something? Show this command again... with no modifications... dpkg -l *resolv*, Why no resolvconf? – heynnema Mar 4 at 5:21
2

No wonder I said "Something is wrong here". In your "customization", you've kind of made an unnecessary mess of things. Stop trying to defeat the system. Sorry.


In /etc/netplan/*.yaml you've combined NetworkManager and netplan script. Your .yaml file should look like this...

network:
  version: 2
  renderer: NetworkManager

This information belongs in NetworkManager GUI connection profile, or in /etc/network/interfaces, in NetworkManager speak... not netplan speak...

ethernets:
    eth0:
      addresses: [192.168.0.11/24, 192.168.0.10/24] (why two addresses?)
      gateway4: 192.168.0.1

  • reinstall resolvconf
  • reset /etc/resolv.conf symlink
    • see below for link information
    • and don't manually edit this file
  • edit /etc/systemd/resolved.conf (see below for instructions)
  • remove dns=dnsmasq from /etc/network/interfaces
  • remove dnsmasq* unless you can explain why you need it

Regarding dnsmasq and systemd-resolved...

Do a ps auxc | grep -i dns and ps auxc | grep -i resolv and look for dnsmasq and systemd-resolved, and if both are running, you need to disable the DNS part of systemd-resolved by editing /etc/systemd/resolved.conf and...

change:

#DNSStubListener=yes

to:

DNSStubListener=no

then restart systemd-resolve and dnsmasq, or reboot.

You MAY need to reset the symlink that is /etc/resolv.conf (if dnsmasq is not running)...

sudo mv /etc/resolv.conf /etc/resolv.conf.OLD # save the old symlink

sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf # create new symlink

Note: original symlink is...

sudo ln -s /run/resolvconf/resolv.conf /etc/resolv.conf

  • Thanks a lot heynnema, I wasn't messing up my system, I was just trying to get what I want based on all sorts of (weird/out-dated) answers I found from the internet. :-) Glad to find askubuntu to be the prefect place for my weird questions. Thanks at lot for all your helps! – xpt Mar 4 at 17:08
  • +1 for "Stop trying to defeat the system." – chili555 Mar 4 at 21:40
  • @chili555 that's funny... giggle. – heynnema Mar 4 at 23:59

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.