Assign IP based on if giaddr is even or odd

Stephen Donovan stephen.donovan at gmail.com
Wed Jan 6 17:53:32 UTC 2021


Hello Gurus

I am trying to deploy a series of routers that can use DHCP to provide an
IP address to the neighbouring router and once the router is reachable
management software will push configuration to it.

All links between the routers are /31 subnets and it is possible that each
router could be configured in each direction, for example if router A is
up, then it will offer an address to router B, however if router B is up
before A then B will offer an address to A.

I tried the sample subnet shown below and everything works, if I use the
full giaddr in the match statement, however if I try to simplify it to
match the class if the giaddr is even or odd doesn't work. My attempt on
using a regex to match even/odd is commented out.

Does anyone have any suggestions on how I could use a different match to
hand out different addresses based on if the giaddr is even or odd? Did I
make a fundamental mistake in my match statement. I'm willing to use the
full match, but would like to simplify if possible.

Thanks in advance
Steve

#test subnet
subnet 11.12.13.44 netmask 255.255.255.254 {
log(debug, concat ("giaddr: ", binary-to-ascii(10,8, ".", packet(27,1)))) ;
class "cw" {
#match if (binary-to-ascii(10,8, ".", packet(27,1)) ~~
#"^\d*[02468]$");
match if (binary-to-ascii(10,8, ".", packet(24,4)) =
"11.12.13.44");
}

pool
{
allow members of "cw";
range 11.12.13.45 11.12.13.45;
option routers 11.12.13.44;
option subnet-mask 255.255.255.254;
}

pool
{
deny members of "cw";
range 11.12.13.44 11.12.13.44;
option routers 11.12.13.45;
option subnet-mask 255.255.255.254;
}

}
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/dhcp-users/attachments/20210106/ef029162/attachment.htm>


More information about the dhcp-users mailing list