Fedora Account System
Red Hat Associate
Red Hat Customer
Description of problem: When booting up, dnsmasq fails to start because of the error: unknown interface enp3s0 It seems that NetworkManager has not brought the Ethernet interface up in time, so it fails to start. Version-Release number of selected component (if applicable): NetworkManager-1.8.2-1.fc26.x86_64 dnsmasq-2.76-5.fc26.x86_64 How reproducible: It happens every time I reboot. I have to start dnsmasq manually after logging in. Steps to Reproduce: 1. Reboot 2. dnsmasq fails to start 3. login and start the service manually Actual results: [root@fedora ~]# systemctl status dnsmasq ● dnsmasq.service - DNS caching server. Loaded: loaded (/usr/lib/systemd/system/dnsmasq.service; enabled; vendor preset: disabled) Active: failed (Result: exit-code) since Sat 2017-10-14 01:21:07 SAST; 14min ago Process: 1235 ExecStart=/usr/sbin/dnsmasq -k (code=exited, status=2) Main PID: 1235 (code=exited, status=2) Oct 14 01:21:04 fedora.localdomain systemd[1]: Started DNS caching server.. Oct 14 01:21:07 fedora.localdomain dnsmasq[1235]: dnsmasq: unknown interface enp3s0 Oct 14 01:21:07 fedora.localdomain systemd[1]: dnsmasq.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Oct 14 01:21:07 fedora.localdomain systemd[1]: dnsmasq.service: Unit entered failed state. Oct 14 01:21:07 fedora.localdomain systemd[1]: dnsmasq.service: Failed with result 'exit-code'. [root@fedora ~]# systemctl start dnsmasq [root@fedora ~]# systemctl status NetworkManager-wait-online ● NetworkManager-wait-online.service - Network Manager Wait Online Loaded: loaded (/usr/lib/systemd/system/NetworkManager-wait-online.service; enabled; vendor preset: enabled) Active: failed (Result: exit-code) since Sat 2017-10-14 01:21:42 SAST; 15min ago Docs: man:nm-online(1) Process: 1212 ExecStart=/usr/bin/nm-online -s -q --timeout=60 (code=exited, status=2) Main PID: 1212 (code=exited, status=2) Oct 14 01:21:03 fedora.localdomain systemd[1]: Starting Network Manager Wait Online... Oct 14 01:21:29 fedora.localdomain nm-online[1212]: Error: Could not create NMClient object: Timeout was reached Oct 14 01:21:42 fedora.localdomain systemd[1]: NetworkManager-wait-online.service: Main process exited, code=exited, status=2/INVALIDARGUMENT Oct 14 01:21:42 fedora.localdomain systemd[1]: Failed to start Network Manager Wait Online. Oct 14 01:21:42 fedora.localdomain systemd[1]: NetworkManager-wait-online.service: Unit entered failed state. Oct 14 01:21:42 fedora.localdomain systemd[1]: NetworkManager-wait-online.service: Failed with result 'exit-code'. [root@fedora ~]# cat /usr/lib/systemd/system/dnsmasq.service [Unit] Description=DNS caching server. After=network.target [Service] ExecStart=/usr/sbin/dnsmasq -k [Install] WantedBy=multi-user.target [root@fedora ~]# cat /usr/lib/systemd/system/NetworkManager-wait-online.service [Unit] Description=Network Manager Wait Online Documentation=man:nm-online(1) Requisite=NetworkManager.service After=NetworkManager.service Before=network-online.target [Service] Type=oneshot ExecStart=/usr/bin/nm-online -s -q --timeout=60 RemainAfterExit=yes [Install] WantedBy=network-online.target [root@fedora ~]# grep enp /etc/dnsmasq.conf interface=enp3s0 Expected results: dnsmasq should start. It depends on the ethernet interface being ready. Surely there should be an easy way to ensure this? Additional info:
i'm seeing something similar where dnsmasq service is not waiting long enough. I have `listen-address=x.x.x.x` in my config and I see ``` Oct 16 17:59:10 origin-master-1.localdomain systemd[1]: Started DNS caching server.. Oct 16 17:59:10 origin-master-1.localdomain dnsmasq[812]: dnsmasq: failed to create listening socket for x.x.x.x: Cannot assign requested address Oct 16 17:59:10 origin-master-1.localdomain dnsmasq[812]: failed to create listening socket for x.x.x.x: Cannot assign requested address Oct 16 17:59:10 origin-master-1.localdomain systemd[1]: dnsmasq.service: Main process exited, code=exited, status=2/INVALIDARGUMENT ``` if I restart dnsmasq after being booted for a while it works fine. I'll note I've seen this for a while just haven't got around to reporting it. That means I've seen it on dnsmasq-2.76-3.fc26.x86_64 and the newer `2.76-5.fc26.x86_64`.
FYI: ubuntu bug for similar problem: https://bugs.launchpad.net/ubuntu/+source/dnsmasq/+bug/1531184 Petr, can we get you to look at this?
Hi, I think this issue is better solved by using bind-dynamic instead of bind-interfaces. network-online.target is not used intentionally. If system is configured to use dnsmasq as DNS resolver of the system, network-online.target may not be active until dnsmasq is ready. It must not wait for network-online.target by default. # dnsmasq.conf interface=eth0 bind-dynamic allows start of dnsmasq even when eth0 is still down. As soon as it is up, it will bind the interface and listen on it. I think this is exactly what is required in this case. Is there reason why is bind-dynamic not suitable for your case? I would close the bug if it helps.
Thanks Petr. I'm going to work in an upstream issue [1] to see if we can use bind-dynamic. [1] https://github.com/openshift/openshift-ansible/issues/5935 In the meantime, do you have any influence on dnsmasq upstream? It would be great if upstream could be modified to add a helpful message during boot. i.e. if I can't bind to eth0 when dnsmasq is started and bind-dynamic is not in the config then give a message to the user that says 'couldn't bind to address on eth0, maybe you would like to use bind-dynamic in dnsmasq config'.
(In reply to Petr Menšík from comment #3) > Hi, > > I think this issue is better solved by using bind-dynamic instead of > bind-interfaces. network-online.target is not used intentionally. If system > is configured to use dnsmasq as DNS resolver of the system, > network-online.target may not be active until dnsmasq is ready. It must not > wait for network-online.target by default. > > # dnsmasq.conf > interface=eth0 > bind-dynamic > > allows start of dnsmasq even when eth0 is still down. As soon as it is up, > it will bind the interface and listen on it. I think this is exactly what is > required in this case. > > Is there reason why is bind-dynamic not suitable for your case? I would > close the bug if it helps. Hi Petr FANTASTIC!! Using "bind-dynamic" works for me. To answer your question: the reason I didn't use bind-dynamic is because I didn't know it existed!! It's not mentioned anywhere in the comments of the sample dnsmasq.conf file. I would suggest that it be added, as it's most useful in my case. Many thanks.
Closing the bug, can be fixed by already supported configuration. bind-dynamic is supported only on Linux, bind-interfaces on any other platform. I think default configuration and manual page are place for improvement. I guess code is not best place to document behaviour. Especially if failed bind to interface might be because incorrectly spelled interface name.
*** Bug 1984618 has been marked as a duplicate of this bug. ***