Have ISC dhcpd cycle through a list of gateways when giving out leases
-
26-10-2019 - |
سؤال
I'm looking for a way to get the ISC's dhcpd to work with several gateways/routers. The behaviour I am after is the following (imagine we have 3 gateways) :
Client A requests a lease, gets gateway #1
Client B requests a lease, gets gateway #2
Client C requests a lease, gets gateway #3
Client D requests a lease, gets gateway #1
And so on...
I am working through the source, but am having difficulty locating the part I am going to have to modify to get this working... (ie: I am clueless & totally lost in the source tree)
I know several routers can be specified by the option-routers, but this does not give the functionality I want.
Any help or pointers to documentation about the dhcpd source would be much appreciated :)
Cheers,
~Thomas
المحلول
Have you considered doing this with conditional evaluation in the dhcpd.conf
file? For example, this should assign the three gateways as per your question:
if suffix(binary-to-ascii(3, 32, "", leased-address), 1) = "0" {
option routers gateway1;
} elsif suffix(binary-to-ascii(3, 32, "", leased-address), 1) = "1" {
option routers gateway2;
} else {
option routers gateway3;
}
(Note: untested, I don't have a DHCP testbed network handy!)