systemd starts dnsmasq before starting network manager

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