3

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 and systemctl 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.
8
  • First verify the start order with 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.html
    – cmak.fr
    Commented Mar 10, 2019 at 14:12
  • 1
    As I answered in your TWO prior questions regarding your network configuration... you have to disable systemd-resolved DNSStubListener=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?
    – heynnema
    Commented Mar 10, 2019 at 15:33
  • @heynnema, thanks for helping, please see my updated OP.
    – xpt
    Commented Mar 10, 2019 at 21:06
  • I read your update. And no... you don't "added DNSStubListener=no" to anything, you just edit /etc/systemd/resolved.conf. And no... you don't try and systemctl stop/disable systemd-resolved. You just need to follow my instructions and then leave it alone. Sorry if I sound a little miffed... this is the third time I'm recommending this, and that you stop trying to defeat the system. It was designed to work as it is... not some "customized" vision in your head. Sorry...
    – heynnema
    Commented Mar 11, 2019 at 0:34
  • Sorry to be dense @heynnema, hmm... in my defense, I think the problem is that the question "Replace systemd-resolved with dnsmasq" was not fully answered, as I've explained better to "list the correct steps on how to replace systemd-resolved with dnsmasq, instead of correcting what I've been doing wrong". So I have to rely on steps in askubuntu.com/questions/898605 to cover the missing pieces, and systemctl stop/disable systemd-resolved was the accepted answer. I was not dong some "customized" vision in my head but following instructions.
    – xpt
    Commented Mar 11, 2019 at 14:30

2 Answers 2

0

I had the same issue, but only on 16.04 systems updated to 18.04. I am also using dnsmasq as my LAN DNS and DHCP server.
On a freshly installed 18.04, it is working out of the box, without having to modify /etc/systemd/resolved.conf (DNSStubListener).

0

Unresolved bug in Ubuntu 18.04. I'll show you how I worked around it. Maybe others have a more elegant solution, but I'll start the ball rolling with my own.

The problem lives in the [Unit] section in the After= directive which must be modified as follows to raise dnsmasq.service unbroken on boot:

sed -i 's/After=network.target/After=NetworkManager-wait-online.service/' /lib/systemd/system/dnsmasq.service

When testing I initially tried After=NetworkManager.service which seemed a sensible choice. But after a reboot dnsmasq was still rising-up broken on boot. So I did:

systemd-analyze critical-chain

And found NetworkManager-wait-online.service started even later. That's how I found the appropriate relative order in which to raise dnsmasq.service. HTH you if you've stumbled onto this issue-

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .