Systemd-Resolve High CPU Usage After Update to 17.04 – Fix Guide

dnssystemdsystemd-resolvedtorxubuntu

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)

Best Answer

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.