[Dnsmasq-discuss] Having dnsmasq coexist with other dhcp server
Luigi Baldoni
aloisio at gmx.com
Wed Oct 25 11:23:56 UTC 2023
Sent: Tuesday, October 24, 2023 at 10:15 PM
From: "Simon Kelley" <simon at thekelleys.org.uk>
>
> On 18/10/2023 08:58, Luigi Baldoni via Dnsmasq-discuss wrote:
> > Hello,
> > I'm having a hard time making dnsmasq run together with kea-dhcp4-server on the same machine.
> > Even though they listen on different interfaces, the first one prevents the other from starting.
> > With the old isc-dhcp-server, "bind-interfaces" was enough. But now strace shows
> > 'bind(4, {sa_family=AF_INET, sin_port=htons(67), sin_addr=inet_addr("0.0.0.0")}, 16) = -1 EADDRINUSE (Address already in use)'
> > no matter how much I tinker with the configuration.
> >
> > Any ideas?
>
> This is tricky. Making DHCP work for IPv4 really requires binding the
> wildcard address, 0.0.0.0 and this makes running multiple servers on
> different interface of the same machine problematic. Dnsmasq does its
> best, and pretty much works for multiple dnsmasq instances. There are
> two different actions needed: 1) Set the socket option SO_REUSEPORT on
> the DHCP socket: this allows multiple processes to bind the same port
> number. Dnsmasq always does this when bind-interfaces is set. 2) Bind
> the socket to a physical interface, so that packets send to
> 255.255.255.255 get send to the correct dnsmasq instance based on which
> interface they arrive on. Dnsmasq does this when bind-interfaces is set,
> and it's configured using --interface to listen on exactly one interface.
>
> The problem you have, I think, is that Kea is not sharing nicely in the
> same way. The Kea code on github doesn't set SO_REUSEPORT for DHCPv4 (it
> does for DHCPv6) The old ISC server does raw packet IO to avoid the
> problems with the kernel IP stack for DHCPv4, and that's probably why it
> works. I've not looked at Kea in detail, but it's likely that it uses
> the same approach to making DHCPv4 work using the kernel IP stack that
> dnsmasq does, but it looks like it's not had the time that dnsmasq has
> to accrete the workarounds needed to run multiple DHCP servers in one
> kernel.
>
> I'd suggest that this is a Kea problem, not a dnsmasq one.
Thanks for the in-depth answer.
Will file a bug report upstream and see what the ISC people can tell me.
Regards
More information about the Dnsmasq-discuss
mailing list