29

I have recently upgrade my Xubuntu from 16.10 to 17.04.

Every things works well except systemd-resolve. some times it makes cpu usage too high and I don't know why this issue has been happend.

And here is the top command output:

  PID USER      PR  NI    VIRT    RES    SHR S  %CPU %MEM     TIME+ COMMAND                               
  1114 systemd+  20   0   51532   6744   4504 R   100  0.0   9:51.67 systemd-resolve                       
  1152 dnsmasq   20   0   64360   2892   2480 R  38.9  0.0   4:05.53 dnsmasq                               
  1245 root      20   0  376644  89644  64436 S   1.7  0.5   0:35.69 Xorg                                  
  1624 asus      20   0  370160  45820  28488 S   0.7  0.3   0:00.90 python2                               
  2238 asus      20   0 2562816 553112 128492 S   0.7  3.4   2:41.20 firefox                               
    16 root      20   0       0      0      0 S   0.3  0.0   0:01.05 ksoftirqd/1                           
   708 root     -51   0       0      0      0 S   0.3  0.0   0:01.20 irq/95-ELAN1000                       
  1302 root     -51   0       0      0      0 S   0.3  0.0   0:03.68 irq/142-nvidia                        
  1734 asus      20   0  483388  11060   8560 S   0.3  0.1   0:05.45 conky                                 
  2820 root      20   0       0      0      0 S   0.3  0.0   0:00.14 kworker/5:1                           
  3420 asus      20   0   53384   3932   3200 R   0.3  0.0   0:00.76 top                                   

I don't know why this issue has been happend but usually it's occured when run some commands like sudo apt update .

(I'm using tor and obfs4proxy, It's may be helpful for answer)

4 Answers4

37

I had a similar conflict between systemd-resolve and dnsmasq on port 53.

https://unix.stackexchange.com/questions/304050/how-to-avoid-conflicts-between-dnsmasq-and-systemd-resolved

and

https://github.com/systemd/systemd/pull/4061

led me to add DNSStubListener=no in /etc/systemd/resolved.conf and then sudo service systemd-resolved restart.

  • 5
    This worked, but then I had no DNS and couldn't access websites by name. – abalter Sep 14 '17 at 04:43
  • @abalter My issue was specifically a loop between systemd-resolve and dnsmasq, so turning off one worked for me. If you're still having this issue, I'd be curious what your top looks like and if that reveals a loop between systemd-resolve and another utility instead. – MetricMike Sep 20 '17 at 00:45
  • Yeah, does this resolved do the same thing as dnsmasq? Should we disable one of them for good? Because it doesn't really make sense to have two local dns resolvers (I'm still not convinced about one TBH but I decided to go with the flow and not customize my config) – Ivan Anishchuk Nov 27 '17 at 18:59
  • omg... that felt so good. the silencing of my cpu fan the instant I restarted systemd-resolved... but now chrome appears to be spiking to 100? – Jonny Asmar Dec 29 '17 at 18:27
  • 1
    Yeh -- this solution seemed to have undesirable side-effects (including killing thunderbird)... See the below answer from markackerman for the trick that worked for me. – Jonny Asmar Dec 29 '17 at 18:31
  • I couldn't access any website following this change – ubuntu_uk_user Apr 11 '19 at 10:16
25

Caused Problems with other Apps (teamViewer in my case)

Suggested by another Steps of solution

Add the line DNSMASQ_EXCEPT=lo to /etc/default/dnsmasq

sudo nano /etc/default/dnsmasq

Restart dnsmasq via

sudo service systemd-resolved restart

Say Thanks If I helped, It went back to normal and does NOT screw around with other apps, as the previous method DID.

Cheers, Mark

  • 1
    sudo nano is not the way to edit configs, sudoedit should be used instead. And systemctl is the way to restart services with systemd. Above all else, it doesn't work for me, I still see 100% CPU usage. – Ivan Anishchuk Nov 27 '17 at 18:51
  • And doesn't this effectively disables dnsmasq? Why not disable it completely then? – Ivan Anishchuk Nov 27 '17 at 19:16
  • @IvanAnishchuk you are half right. It does disable the DNS mechanism of DNSMasq but it has also a DHCP mechanism. – Moshe May 30 '19 at 12:07
10

systemd-resolved gets crazy when somebody modifies the file /etc/resolv.conf, which is meant to be pointing to its own listening address 127.0.0.53.

That somebody could be any script triggered by networking events (VPN coming up, or down, DHCP, etc.)

If you set the nameserver back to 127.0.0.53, then systemd-resolved will "calm down" few seconds later.

Assuming that everybody's respecting the rules, and only using resolvconf for modifying the resolver's configuration, you can also do this:

The file /etc/resolvconf/interface-order specifies the order in which nameservers will be used, depending on the network interface they were received from.

If you add an entry for systemd-resolved at the top of the file, it will always be considered first and the file will not be modified.

xalkina
  • 101
  • 1
  • 2
  • 2
    So, both answers above ended up failing me in the end. But this one behaved just as predicted. Reverted my resolv.conf (nameserver was set to 127.0.0.1 for some reason). Didn't even need to restart systemd and things quited down again. Watching my processes now, dnsmasq is off the radar again, where it should be! THIS should be the accepted answer. Thank you @xalkina! – Jonny Asmar Dec 29 '17 at 18:51
  • 1
    This issue seems to return after a reboot... Any ideas what would be modifying my resolv.conf? – Jonny Asmar Dec 31 '17 at 20:15
  • 1
    This solution works for me either (while the two above doesn't) – Alex Hoppus Jan 21 '18 at 12:55
3

I had the same Problem in 18.04. systemd-resolved and dnsmasq tend to loop. I solved it this way:

Add or uncomment the following line in /etc/default/dnsmasq:

IGNORE_RESOLVCONF=yes

Create your own resolv file (/etc/resolv.personal) to define nameservers. You can use any nameserver here. I took two from OpenNIC.

nameserver 5.132.191.104
nameserver 103.236.162.119

In /etc/dnsmasq.conf add or uncomment the following line:

resolv-file=/etc/resolv.personal

Then restart dnsmasq and disable the default resolver: systemd-resolved.

sudo service dnsmasq restart
sudo systemctl stop systemd-resolved
sudo systemctl disable systemd-resolved