8

A bizarre problem that I haven't found anywhere else on the internet, hinting it's probably me f'ing something up, but what?

Trying to start dnsmasq.service, no matter if on boot or from user session when all network services are available and working, fails with unknown interface enp2s0 error... except the entire rest of the system claims it's up.

andrzej@andrzej-PC ~ $ sudo systemctl start dnsmasq
Job for dnsmasq.service failed because the control process exited with 
error code. See "systemctl status dnsmasq.service" and "journalctl -xe" for details.
andrzej@andrzej-PC ~ $ systemctl status dnsmasq
● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; disabled; vendor preset:
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: failed (Result: exit-code) since Mon 2017-07-10 02:09:41 CEST; 3s ago
  Process: 5551 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=
  Process: 5548 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUC

Jul 10 02:09:41 andrzej-PC systemd[1]: Starting dnsmasq - A lightweight DHCP and
Jul 10 02:09:41 andrzej-PC dnsmasq[5548]: dnsmasq: syntax check OK.
Jul 10 02:09:41 andrzej-PC dnsmasq[5551]: dnsmasq: unknown interface enp2s0
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Control process exited, 
Jul 10 02:09:41 andrzej-PC systemd[1]: Failed to start dnsmasq - A lightweight D
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Unit entered failed stat
Jul 10 02:09:41 andrzej-PC systemd[1]: dnsmasq.service: Failed with result 'exit

Right, except:

andrzej@andrzej-PC ~ $ ifconfig
enp2s0    Link encap:Ethernet  HWaddr /*correct address*/  
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:921 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:147421 (147.4 KB)

and same for ip addr:

2: enp2s0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    link/ether /*same*/ brd ff:ff:ff:ff:ff:ff

and finally:

andrzej@andrzej-PC ~ $ cat /sys/class/net/enp2s0/operstate
up

What? Oh, and my config file looks like this:

port=0
interface=enp2s0
dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-boot=/install/netboot/pxelinux.0
dhcp-option-force=209,install/netboot/pxelinux.cfg
dhcp-option-force=210,/
dhcp-option-force=66,192.168.0.1
enable-tftp
tftp-root=/mnt
AdminBee
  • 21,637
  • 21
  • 47
  • 71
Deuxis
  • 323
  • 2
  • 10
  • this interface might be up but it does not look configured, I cannot see any ip and no packet has been ever received on it. Be sure to be able to ping it even from itself – M4rty Jul 10 '17 at 13:00
  • That's because it's an ethernet interface I'm trying to use to set up PXE boot on another computer. I connect with my home network via a wireless card, of course having a different interface. – Deuxis Jul 10 '17 at 15:58
  • Oh, I forgot to mention, once after a reboot dnsmasq started working for no apparent reason, and when trying to PXE boot ifconfig showed packets going both ways, but the "client" computer didn't receive any DHCP offer and when I restarted dnsmasq it failed with the same error again. – Deuxis Jul 13 '17 at 19:27
  • I have the same error trying to do the same thing (set up PXE boot), @Deuxis, did you find any solution? – Hadrien TOMA Sep 17 '17 at 08:09
  • Sadly not, @HadrienTOMA. It simply became apparent to me that the computer I'm trying to revive isn't worth the effort. Good luck with your search! – Deuxis Sep 19 '17 at 14:18

4 Answers4

3

modify DNSMasq service description

sudo nano /lib/systemd/system/dnsmasq.service

Change Requires and After so that it starts after interfaces are up.

Requires=network-online.target
After=network-online.target
Matt B
  • 31
  • 2
  • 1
    this worked for me on RockyLinux (based on RHEL8), however I used an override drop in file /etc/systemd/system/dnsmasq.service.d/override.conf rather than edit the service definition directly, to prevent my changes getting lost during software updates. – MNB Jul 07 '22 at 23:16
  • Worked for me on Ubuntu 22.04.1 as well – Steve Weaver Jan 31 '23 at 18:58
1

System restart helped - dnsmasq started without issues. It is possible that device config for the interface configured to use with dnsmasq were not yet in force

TimSparrow
  • 111
  • 2
1

I had the same situation - dnsmasq refusing to start on a secondary eth interface used for PXE, connected back-to-back (no switch) to another computer.

As soon as I had a link up (some network traffic, NIC lights went on) dnsmasq started ok.

I know this is not very scientific, but it worked for me (Ubuntu 20.04)

Joel
  • 26
  • 1
  • This seems to describe the situation but not actually provide a solution. How to ensure the link is up can be seen in @Matt B's answer or perhaps somewhere else. – lwileczek May 17 '22 at 19:55
1

When you're using Linux you can enable bind-dynamic. As per the documentation:

Enable a network mode which is a hybrid between --bind-interfaces and the default.  Dnsmasq binds the address of individual interfaces, allowing multiple dnsmasq instances, but if new interfaces or addresses appear, it automatically listens on those (subject to any access-control configuration).  This makes dynamically created interfaces work in the same way as the default.  Implementing this option requires non-standard networking APIs and it is only available under Linux.  On other platforms it falls-back to --bind-interfaces mode.

Remember to remove bind-interfaces.

Reference: https://thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html