[Dnsmasq-discuss] 2 Nics, 2 domains, dhcp, trouble

Simon Kelley simon@thekelleys.org.uk
Thu, 16 Dec 2004 18:01:42 +0000


This is a multi-part message in MIME format.
--------------030906030301050904010004
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit

JP M wrote:
> Hi, list.
> I have enjoyed using dnsmasq for a while now. Really
> great, IMO.
> 
> I have a rather complicated setup, running on debian
> 2.6. It *used to work ok*, and now -after reckless
> updates- fails with "address already in use" :
> - 3 nics, shorewall firewall : eth0, br0, br1
> - OpenVPN tunnels running on br0 (VPN zone) and br1
> (LAN zone).
> - Dnsmasq running on br0 (domain vpn.mynet) and br1
> (domain lan.mynet), using both dns and dhcp features.
> 
> To achieve the Dnsmasq part, I used a split conf, and
> start 2 daemons.
> The one for the Lan is setup like:
> domain=lan.mynet
> local=/lan.mynet/
> listen-address=127.0.0.1
> listen-address=192.168.1.1 <- this is br1
> bind-interfaces
> expand-hosts
> domain-suffix=lan.mynet
> dhcp-range=192.168.1.11,192.168.1.254,10h
> dhcp-option=6,192.168.1.1
> 
> The one for the VPN is setup like this:
> domain=vpn.mynet
> local=/vpn.mynet/
> #listen-address=127.0.0.1
> listen-address=192.168.2.1 <- this is br0
> bind-interfaces
> expand-hosts
> domain-suffix=vpn.mynet
> dhcp-range=192.168.2.100,192.168.2.253,1h
> dhcp-option=6,192.168.2.1
> 
> At some point in time (early 2.x versions) this setup
> was working ok.

That's using dnsmasq in a way that I never envisaged! The attached patch 
should make it work again in 2.19.

Note that you current configuration has a big problem: the two instances 
of dnsmasq will trample on each other's lease files. You need to add 
something like

--dhcp-leasefile=/var/lib/misc/dnsmasq.leases.br0

to fix that.

Cheers,

Simon.

--------------030906030301050904010004
Content-Type: text/plain;
 name="patch"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="patch"

diff -Naur src.orig/dhcp.c src/dhcp.c
--- src.orig/dhcp.c	2004-12-13 07:33:29.000000000 +0000
+++ src/dhcp.c	2004-12-16 17:54:30.000000000 +0000
@@ -34,6 +34,10 @@
       setsockopt(fd, SOL_SOCKET, SO_BROADCAST, &oneopt, sizeof(oneopt)) == -1)  
     die("failed to set options on DHCP socket: %s", NULL);
   
+  if ((daemon->options & OPT_NOWILD) &&
+      setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, &oneopt, sizeof(oneopt)) == -1)
+    die("failed to set SO_REUSEADDR on DHCP socket: %s", NULL);
+
   saddr.sin_family = AF_INET;
   saddr.sin_port = htons(DHCP_SERVER_PORT);
   saddr.sin_addr.s_addr = INADDR_ANY;

--------------030906030301050904010004--