[Dnsmasq-discuss] preventing address allocation

Simon Kelley simon@thekelleys.org.uk
Thu, 09 Jun 2005 12:17:19 +0100


Benjamin Collar wrote:
> Greetings folks
> 
> I've got a situation that I haven't found a great answer to so far, and
> I was hoping you all could help.
> 
> We've got a set up like this:
> 
> host1: 
>   eth0, eth1 are on the same physical lan-segment
>   eth0 handles range 10.0.150.10-10.0.150.255
>   eth1 handles range 10.128.150.10-10.128.150.255
>   dnsmasq is configured like this (partially):
> 
> interface=eth0
> interface=eth1
> dhcp-range=10.0.150.10,10.0.150.255,12h
> dhcp-range=10.128.150.10,10.128.150.255,12h
> dhcp-host=id:CLIENT1,10.0.150.10,CLIENT1,45m
> dhcp-host=id:CLIENT2,10.128.150.32,CLIENT2,45m
> 
> CLIENT1:
>   MAC address is not sent as identifier, instead client-id is CLIENT1
>  
> CLIENT2:
>   like CLIENT1
> 
> So the point is, client1 gets assigned a known address and so does
> client2. All configuration is in one place. excellent.
> 
> So now let's say client1's dhcpcd starts and sends a UDP packet, asking
> for a dhcp server and an address. The packet arrives at at eth0 and
> dnsmasq says "yep, you're CLIENT1, here's your address." However, the
> packet also arrives at eth1 and dnsmasq says, "that doesn't match any
> context. Hmm. Here, CLIENT1, try this address" and allocates an unused
> address from its allowed range for eth1.
> 
> And it's the second part that I want to disable. If a request comes to
> an interface and the request is not recognized from the dhcp-host list,
> dnsmasq should not allocate an unused address.

That's already implemented, change your dhcp-range configs from

dhcp-range=10.0.150.10,10.0.150.255,12h
dhcp-range=10.128.150.10,10.128.150.255,12h

to

dhcp-range=10.0.150.10,static,12h
dhcp-range=10.128.150.10,static,12h

Which tells dnsmasq to only allocate explicitly configured addresses on 
those subnets. Note that the actual address in each line doesn't matter, 
it just specifies the subnet (in conjunction with the netmask set on the 
interface.)

HTH

Simon.