How to configure dhcpd to send a preferred IP-address for a client-class ?
Martin Robrecht
Martin.Robrecht at bruker-biospin.de
Mon Apr 2 15:54:54 UTC 2007
Martin Robrecht wrote:
>
> How to configure dhcpd to send a preferred IP-address for a client-class ?
>
> My company uses the second ethernet-adapter at our customers PC's to
> control our devices in a subnet which has the same IP-configuration
> at each customers site. There the DHCP-Server services different device-types
> only on the specified second ethernet-adapter.
> There are several thousand devices at all our
> customers sites whose detailed MAC-Addresses are not known.
> Therefore it is not possible for me to configure the dhcp-server
> at our customer sites depending on MAC-Addresses.
> But each device-type sends an specific DHCP client-hostname option
> if it uses DHCP at all.
>
> Our older hardware does not use DHCP and
> our older software expects each device-type at a special IP-address.
> To maintain backward compatibility the DHCP-server sends the same IP-address
> the devices would use without DHCP :
>
> dhcpd.conf looks like this :
>
> class "DEVICE_type_1" { match if option host-name = "device_type_1" ; }
> class "DEVICE_type_2" { match if ( substring ( option host-name, 0,4) = "device_type_2" ); }
>
> subnet x.x.x.0 netmask 255.255.255.0
> {
> pool { range x.x.x.1 ; allow members of "DEVICE_type_1"; }
> pool { range x.x.x.2 ; allow members of "DEVICE_type_2"; }
> pool { # general pool for devices which have no fixed addresses in the field
> range x.x.x.3 x.x.x.254;
> deny members of "DEVICE_type_1";
> deny members of "DEVICE_type_2";
> }
> }
>
> Only one instance of DEVICE_type_x is at a customers site currently.
>
> Problem of this configuration :
>
> 1) If I want to add another device of DEVICE_type_1 , is there any possibility to say
> that the first DHCPREQUEST should get x.x.x.1 ( the preferred address )
> and the second DHCPREQUEST should get an arbitrary IP-address from an other pool ?
>
> I tested a pool declaration with a range of two IP-adresses and the
> combination of two pool declaration for the same class. The DHCP-server ( V3.0.1 )
> always sends the highest unused IP-address of all matching pools
> and as mentioned in other threads this algorithm may change.
>
> 2) It may be necessary to replace an faulty device.
> The new device of the same class will not get an IP-Address
> because the pool is exhausted.
>
> Currently the DHCP-server must be stopped, the leases file must be edited,
> and then the DHCP-server must be restarted. This is error-prone.
>
> a) Can I use Omapi to delete the used lease object ?
> I tried it using omshell but this does not work.
> omshell man-page says "yes" but dhcpd man-page says "currently no" .
>
> b) Can I use Omapi to set the lease state to free ?
>
> c) Can I configure the DHCP-server to reuse the same IP-address
> ignoring the different MAC-addresses if the device belongs to the same class ?
> Of course my preferred solution !
I found a configuration which solves
Problem 1) If I want to add another device of DEVICE_type_1 ...
As seen in
http://marc.info/?l=dhcp-users&m=115321853708102&w=2
allowing the same class in several pool-declarations does not solve my problem,
because the ranges of all matching pools gets merged.
So I tried to put the same type of DHCP client into different classes:
class "DEVICE_type_1" { match if option host-name = "device_type_1" ; }
class "DEVICE_type_1_second" { match if option host-name = "device_type_1" ; }
subnet x.x.x.0 netmask 255.255.255.0
{
pool { range x.x.x.1 ; allow members of "DEVICE_type_1"; }
pool { range x.x.x.2 ; allow members of "DEVICE_type_1_second"; }
pool { # general pool for devices which have no fixed addresses in the field
range x.x.x.3 x.x.x.254;
deny members of "DEVICE_type_1";
deny members of "DEVICE_type_2";
}
}
Now the first request of "device_type_1" gets the IP-address x.x.x.1 of the first pool
and exhausts them. The second request of "device_type_1" gets the IP-address x.x.x.2 .
I can exchange the delivered IP-Addresses by changing the oder of the pool-declarations.
The first matching pool-declaration in dhcpd.conf is used first.
Can I rely on this behaviour of the DHCP-server ( V3.0.1 )
or may it change in the future ?
--
Freundliche Gruesse / kind regards
Martin Robrecht
More information about the dhcp-users
mailing list