[Dnsmasq-discuss] Assigning leases based on relay agent IP address?

Brian Rak brak at gameservers.com
Tue Jun 3 19:30:55 UTC 2014


This seems like a bug.

I modified my config to be this instead:

dhcp-range=set:SUBNETID124862,10.237.2.65,10.237.2.126,255.255.255.192,2h
dhcp-range=set:SUBNETID124844,10.237.4.1,10.237.4.62,255.255.255.192,2h

Looking at the code, I see this in the option parser:

             if (k >= 3 && strchr(a[2], '.') &&
                 ((new->netmask.s_addr = inet_addr(a[2])) != (in_addr_t)-1))
               {
                 new->flags |= CONTEXT_NETMASK;
                 leasepos = 3;
                 if (!is_same_net(new->start, new->end, new->netmask))
                   ret_err(_("inconsistent DHCP range"));
               }

Perhaps I'm not understanding this, but does this mean that the netmask 
value is only used if mode is not specified?  That's what seems to be 
happening to me.

I added a call to rfc2131.c in the 'guess the netmask for relayed 
networks' section, and sure enough dnsmasq was guessing netmasks for all 
my defined networks.  This would explain why this was happening, since 
it was guessing a class A network here.


On 6/2/2014 5:31 PM, Brian Rak wrote:
> How can I use dhcp-match with the 'Relay agent IP address' part of the 
> packet?
>
>
> I'm trying to manage DHCP for a bunch of different networks with one 
> DHCP server.  I'd like to determine which network to use based on 
> which subnet the relay server's IP address is in.
>
> I've got a bunch of lines like this:
>
> dhcp-range=set:SUBNETID124862,10.237.2.65,10.237.2.126,auto,255.255.255.192,2h 
>
> dhcp-range=set:SUBNETID124844,10.237.4.1,10.237.4.62,auto,255.255.255.192,2h 
>
>
> However, when a DHCPDISCOVER comes in, dnsmasq just picks a random 
> network to use.   As an example:
>
> dnsmasq-dhcp[31908]: 2740340080 vendor class: udhcp 1.12.0
> dnsmasq-dhcp[31908]: 2740340080 DHCPDISCOVER(eth1) 00:25:90:d7:c6:7c
> dnsmasq-dhcp[31908]: 2740340080 tags: SUBNETID124844, eth1
> dnsmasq-dhcp[31908]: 2740340080 DHCPOFFER(eth1) 10.237.4.39 
> 00:25:90:d7:c6:7c
>
> The initial DHCPDISCOVER came in via 10.237.2.65, but a completely 
> different subnet was used instead. (Also, is it possible to log the 
> relay IP address?)
>
> tshark shows this:
>
> Bootstrap Protocol
>     Message type: Boot Request (1)
> ...
>     Bootp flags: 0x0000 (Unicast)
>         0... .... .... .... = Broadcast flag: Unicast
>         .000 0000 0000 0000 = Reserved flags: 0x0000
>     Client IP address: 0.0.0.0 (0.0.0.0)
>     Your (client) IP address: 0.0.0.0 (0.0.0.0)
>     Next server IP address: 0.0.0.0 (0.0.0.0)
>     Relay agent IP address: 10.237.2.65 (10.237.2.65)
>     Client MAC address: 00:25:90:d7:c6:7c (00:25:90:d7:c6:7c)
>
>
> This is with dnsmasq 2.71
>
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss




More information about the Dnsmasq-discuss mailing list