Ubuntu 17.04 - Conflicts between systemd-resolved, dnsmasq and resolvconf
I have switched to Ubuntu 17.04 for a while. And when I was trying to create a WiFi hotspot with create_ap
, I encountered some problems:
Problem 1: 100% CPU usage with systemd-resolved and 33% with dnsmasq
I spotted this problem when I heared my fans spinning crazily. When I do top
, I found the phenomena above.
After some search, I found this post useful:
https://askubuntu.com/questions/909591/systemd-resolve-high-cpu-usage-after-update-to-17-04
However, although I found the solution mentioned in the answer works, I don’t like changing these system default settings very much. Therefore, I chose to turn off DNS function by dnsmasq, as I don’t need that when creating an AP.
Steps of solution
- Change
port=53
toport=0
in/etc/dnsmasq.conf
- Restart dnsmasq
Problem 2: /etc/resolv.conf
always has nameserver 127.0.0.1
in it, instead of nameserver 127.0.0.53
This problem would only affect those programs that read /etc/resolv.conf
for name resolving, for example dig
. Other programs (such as Chrome) tends to use other interfaces for that(I guess), and thus they were not affected.
This problem is because dnsmasq, even though with DNS port=0
, tells resolvconf to use nameserver 127.0.0.1
in its startup script /etc/init.d/dnsmasq
. See the following snippet from that file for reference:
Steps of solution
- Add the line
DNSMASQ_EXCEPT=lo
to/etc/defaults/dnsmasq
- Restart dnsmasq