3

I'm running dnsmasq on Arch Linux on a router with 4 LAN ports for wired, wireless, DMZ and admin_interface. dnsmasq is my dhcp server for my LAN (as well as providing dns functions).

I do not always have things plugged into all 4 LAN ports. But when I reboot the device, I want it to properly come up for the ports where devices are connected, particularly the wired LAN.

My configuration is like this:

If you want dnsmasq to listen for DHCP and DNS requests only on specified interfaces (and the loopback) give the name of the interface (eg eth0) here. Repeat the line for more than one interface.

interface=eth0
interface=eth1
interface=eth2
interface=eth3

I use this config because I do not want dnsmasq running on the WAN port, which I'll call eth4 in this example.

My problem is that if I do not have the cable plugged into eth1 (for example) when the system reboots, dnsmasq does not proceed with eth0 or other valid interfaces; it fails completely as shown here:

Sep 16 14:16:10 router systemd[1]: Starting A lightweight DHCP and caching DNS server...
Sep 16 14:16:10 router dnsmasq[876]: dnsmasq: syntax check OK.
Sep 16 14:16:10 router dnsmasq[879]: dnsmasq: unknown interface eth1
Sep 16 14:16:10 router dnsmasq[879]: unknown interface eth1
Sep 16 14:16:10 router dnsmasq[879]: FAILED to start up
Sep 16 14:16:10 router systemd[1]: dnsmasq.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Sep 16 14:16:10 router systemd[1]: dnsmasq.service: Failed with result 'exit-code'.
Sep 16 14:16:10 router systemd[1]: Failed to start A lightweight DHCP and caching DNS server.

After this, my LAN has no DHCP server and I am missing other critical functionality that dnsmasq provides until I manually go fix it and edit the config file with what is just a temporary (and undesireable) change. Is there a way to make dnsmasq start up with just the valid / connected interface(s) in my situation?

5
  • 1
    except-interface? Sep 16, 2018 at 20:34
  • BTW, I'm not sure that dnsmasq fails to start because cable is not connected - possibly eth1 interface does not exist all when dnsmasq wants to use it. Sep 16, 2018 at 20:47
  • @ArkadiuszDrabczyk If I plug the cable in, dnsmasq starts. Unplug it, I get the errors shown. I had tried 'except-interface' in the past and I do not remember why I gave up on it. But I tried it again just now and it appears it may work. I will test further. Thank you.
    – MountainX
    Sep 16, 2018 at 20:55
  • 1
    @ArkadiuszDrabczyk this cable-unplugged fragility may be related to my udev rules which rename the interfaces (or to something else unique about my system). I thought it was typical behavior, but if it is not, I will look into it further.
    – MountainX
    Sep 16, 2018 at 20:57
  • I have the same problem without any interface-renaming udev rules, when the cable is unplugged. The interface exists, but has no carrier. I believe it's just a dnsmasq bug. My current solution is to have systemd regularly restart the service when it fails. Of course this doesnt help when you want it to serve the other interfaces.
    – MightyPork
    Aug 2, 2021 at 13:33

1 Answer 1

0

While answered in a comment, the full description to the option is (as quoted from the dnsmasq manual):

-I, --except-interface= Do not listen on the specified interface. Note that the order of --listen-address --interface and --except-interface options does not matter and that --except-interface options always override the others. The comments about interface labels for --listen-address apply here.

1
  • A point here is that it looks like you cannot use this method if the intent was to allow ANY interface to be unplugged without failure (and it's not clear that the OP meant this or not). Aug 15, 2021 at 19:31

You must log in to answer this question.

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