dnsmasq doesn't start on boot because its interface isn't up yet

Bug #1531184 reported by Simon Déziel on 2016-01-05
110
This bug affects 22 people
Affects Status Importance Assigned to Milestone
One Hundred Papercuts
High
Unassigned
dnsmasq (Debian)
New
Unknown
dnsmasq (Ubuntu)
Low
Unassigned

Bug Description

My dnsmasq instance uses "interface=br-vz0" and the interface br-vz0 is managed manually in /etc/network/interfaces.

During boot, dnsmasq is started before br-vz0 is created and this causes dnsmasq to exit:

Jan 5 08:56:16 simon-laptop dnsmasq[1008]: dnsmasq: unknown interface br-vz0
Jan 5 08:56:16 simon-laptop dnsmasq[1008]: unknown interface br-vz0
Jan 5 08:56:16 simon-laptop dnsmasq[1008]: FAILED to start up
Jan 5 08:56:17 simon-laptop NetworkManager[937]: <info> NetworkManager (version 1.0.4) is starting...
...
Jan 5 08:56:18 simon-laptop NetworkManager[937]: <info> interface-parser: parsing file /etc/network/interfaces
...
Jan 5 08:56:18 simon-laptop NetworkManager[937]: <info> found bridge ports none for br-vz0
Jan 5 08:56:18 simon-laptop NetworkManager[937]: <info> adding bridge port none to eni_ifaces
Jan 5 08:56:18 simon-laptop NetworkManager[937]: <info> management mode: unmanaged

ProblemType: Bug
DistroRelease: Ubuntu 16.04
Package: dnsmasq 2.75-1
ProcVersionSignature: Ubuntu 4.3.0-5.16-generic 4.3.3
Uname: Linux 4.3.0-5-generic x86_64
ApportVersion: 2.19.3-0ubuntu2
Architecture: amd64
CurrentDesktop: Unity
Date: Tue Jan 5 09:53:30 2016
PackageArchitecture: all
SourcePackage: dnsmasq
UpgradeStatus: No upgrade log present (probably fresh install)

Simon Déziel (sdeziel) wrote :
Simon Déziel (sdeziel) wrote :

Adding the following to the [Unit] section of dnsmasq.service fixes the problem:

 After=network-online.target
 Wants=network-online.target

Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in dnsmasq (Ubuntu):
status: New → Confirmed
Immatix (immatix) wrote :

I believe I was having the same problem, I use the --bind-interfaces option as well as a few --interface options for different interfaces, and dnsmasq would regularly fail to start during boot because one of the interfaces wasn't present yet. Logs show dnsmasq was being started before network.target was reached.

Apr 30 22:23:19 sirius systemd[1]: Starting dnsmasq - A lightweight DHCP and caching DNS server...
Apr 30 22:23:20 sirius dnsmasq[1152]: dnsmasq: syntax check OK.
Apr 30 22:23:20 sirius dnsmasq[1296]: dnsmasq: unknown interface trunk.3
Apr 30 22:23:20 sirius systemd[1]: dnsmasq.service: Control process exited, code=exited status=2
Apr 30 22:23:20 sirius systemd[1]: Failed to start dnsmasq - A lightweight DHCP and caching DNS server.
Apr 30 22:23:20 sirius systemd[1]: dnsmasq.service: Unit entered failed state.
Apr 30 22:23:20 sirius systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
---
Apr 30 22:23:27 sirius systemd[1]: Reached target Network.

I've since added

 After=network-online.target
 Wants=network-online.target

to the [Unit] section of /lib/systemd/system/dnsmasq.service and restarted once and the problem didn't occur, but this hasn't been extensively tested.

Changed in dnsmasq (Ubuntu):
importance: Undecided → High
Changed in hundredpapercuts:
status: New → Confirmed
importance: Undecided → High
Max Chen (maxchen) wrote :

yeah, Immatix! Thanks so much
added

 After=network-online.target
 Wants=network-online.target

to the [Unit] section of /lib/systemd/system/dnsmasq.service

waiting for the fixed to be release

Robie Basak (racb) wrote :

04:47 <rbasak> stgraber: do you have an opinion on the proposed fix for bug 1531184 please?

04:49 <stgraber> rbasak: it's probably fine. Note that anyone who actually has the dnsmasq package installed on their system is likely to run into other problems, so not a big priority for us.

04:49 <stgraber> rbasak: (dnsmasq-base is what we care about in the distro and that doesn't ship the init script)

Changed in dnsmasq (Ubuntu):
importance: High → Low
tags: added: bitesize
Sarraceno (jfhtomas) wrote :

I have openvswitch-switch, which did required from me to apply some changes to systemd service file that seems not to be aware of virtual devices up.

So, bottom line, /etc/network/interface files are taking action in a way that smashes the rush to boot up, so dnsmasq also become a victim, and for me the solution above was not compatible.

So I had to add to dnsmasq.service the follow lines:

     Requires=sys-subsystem-net-devices-<needed device>.device
     After=sys-subsystem-net-devices-<needed device>.device
     Wants=sys-subsystem-net-devices-<needed device>.device

Got the above info from

     systemctl --full | grep subsystem

Best regards!

John Radley (jradxl) wrote :

I have found I needed to add
    After=network-online.target
to dnsmasq.service
to ensure my ethernet port, ens18, is available, on boot.
Using Ubuntu 16.04.2
In my case, I am using dnsmasq as per the PiHole installation where the IP is static and dhcpclient is turned off. But this is clearly not a PiHole problem as it just installs Dnsmasq.
Rather surprised I need to add this report, and that this Bug report isn't a higher Importance and not resolved in 3 months.
Surely loads of users will have this issue?
Kind Regards

Robie Basak (racb) wrote :

> Rather surprised I need to add this report, and that this Bug report isn't a higher Importance and not resolved in 3 months.
Surely loads of users will have this issue?

dnsmasq (as opposed to dnsmasq-base) is not in main in Ubuntu, so relies entirely on community support. It is not installed by default on Ubuntu, and is an "unusual end-user configuration" as far as I can tell. And a workaround appears available and is trivial.

If somebody wants to drive getting a fix landed, please do.

Changed in dnsmasq (Ubuntu):
assignee: nobody → David Britton (davidpbritton)
assignee: David Britton (davidpbritton) → nobody
David Britton (davidpbritton) wrote :
Changed in dnsmasq (Ubuntu):
assignee: nobody → David Britton (davidpbritton)
Changed in dnsmasq (Ubuntu):
status: Confirmed → In Progress
Changed in hundredpapercuts:
status: Confirmed → In Progress
assignee: nobody → David Britton (davidpbritton)
David Britton (davidpbritton) wrote :

Submitted patch upstream, will revisit in a couple weeks before taking on an extra deviation in Ubuntu (since currently we do not have any delta).

Changed in hundredpapercuts:
assignee: David Britton (davidpbritton) → nobody
Changed in dnsmasq (Ubuntu):
assignee: David Britton (davidpbritton) → nobody
Changed in dnsmasq (Debian):
status: Unknown → New
Changed in dnsmasq (Ubuntu):
status: In Progress → Confirmed
Changed in hundredpapercuts:
status: In Progress → Confirmed
Alecz20 (alexguzu) wrote :

I also see this issue after installing pihole which uses dnsmasq.

As a solution until we have a fix available, would it not be better to run `sudo systemctl edit dnsmasq` and add the three lines:
[Unit]
After=network-online.target
Wants=network-online.target

rather than edit /lib/systemd/system/dnsmasq.service directly?

To post a comment you must log in.
This report contains Public information  Edit
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.