Looks to me that my systemd starts dnsmasq before starting network manager. How can I confirm this? How can I force systemd starts dnsmasq after starting network manager?
Reason behind this is, as explained in NetworkManager not updating /var/run/networkmanager/resolv.conf,
- I'm using dnsmasq as my LAN DNS server, and
- I defined my two IP addresses in NetworkManager.
When my system started my dnsmasq is not working, and I found that the reason is it is not listening to my two IP addresses at all. Only after restarting it, it started to listen to my two IP addresses:
$ lsof -i tcp:53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 544 systemd-resolve 13u IPv4 18667 0t0 TCP 127.0.0.53:domain (LISTEN)
dnsmasq 793 dnsmasq 5u IPv4 23719 0t0 TCP localhost.my.box.name:domain (LISTEN)
dnsmasq 793 dnsmasq 7u IPv6 23721 0t0 TCP ip6-localhost:domain (LISTEN)
/etc/init.d/dnsmasq restart
[ ok ] Restarting dnsmasq (via systemctl): dnsmasq.service.
$ lsof -i tcp:53
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
systemd-r 544 systemd-resolve 13u IPv4 18667 0t0 TCP 127.0.0.53:domain (LISTEN)
dnsmasq 17895 dnsmasq 5u IPv4 601091 0t0 TCP 192.168.0.10:domain (LISTEN)
dnsmasq 17895 dnsmasq 7u IPv4 601093 0t0 TCP 192.168.0.11:domain (LISTEN)
dnsmasq 17895 dnsmasq 9u IPv4 601095 0t0 TCP localhost...
$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04.1 LTS
Release: 18.04
Codename: bionic
# my systemd is not the latest but I think that shouldn't matter:
$ apt-cache policy systemd
systemd:
Installed: 237-3ubuntu10
Candidate: 237-3ubuntu10.9
Version table:
237-3ubuntu10.9 500
500 http://security.ubuntu.com/ubuntu bionic-security/main amd64 Packages
500 http://archive.ubuntu.com/ubuntu bionic-updates/main amd64 Packages
*** 237-3ubuntu10 500
500 http://archive.ubuntu.com/ubuntu bionic/main amd64 Packages
100 /var/lib/dpkg/status
Update:
@heynnema, Thanks for the systemd-analyze --no-pager blame
, I've confirmed that the start order is as expected
NetworkManager -> systemd-resolved -> dnsmasq.
So indeed, it is about dnsmasq and systemd-resolved stepping on each others toes. I've added DNSStubListener=no
since. I have two following up questions now.
- Why it is OK for dnsmasq
restart
to work just fine? Its working fine gave me the impression that it is OK to have them both working. - Actually, I used
systemctl stop systemd-resolved
andsystemctl disable systemd-resolved
to completely disable systemd-resolved, instead of just stopping its listener previously. I don't know why it does not persist over reboot.
systemd-analyze --no-pager blame
- You seem to believe that the issue you dont describe comes from the start order. Maybe it just related to some misconfiguration?... Anyway, you can try to modify start order (ie: services/units dependencies) according to the freedesktop reference freedesktop.org/software/systemd/man/systemd.unit.htmlDNSStubListener=no
when also running dnsmasq. If you don't want to do that, dnsmasq and systemd-resolved WILL step on each others toes. Is there some reason why you don't seem to want to do this?