Send dhcp-users mailing list submissions to
        dhcp-users@lists.isc.org

To subscribe or unsubscribe via the World Wide Web, visit
        https://lists.isc.org/mailman/listinfo/dhcp-users
or, via email, send a message with subject or body 'help' to
        dhcp-users-requ...@lists.isc.org

You can reach the person managing the list at
        dhcp-users-ow...@lists.isc.org

When replying, please edit your Subject line so it is more specific
than "Re: Contents of dhcp-users digest..."


Today's Topics:

   1. Assign IP based on if giaddr is even or odd (Stephen Donovan)
   2. RE: Assign IP based on if giaddr is even or odd (Thor Simon)


----------------------------------------------------------------------

Message: 1
Date: Wed, 6 Jan 2021 12:53:32 -0500
From: Stephen Donovan <stephen.dono...@gmail.com>
To: dhcp-users@lists.isc.org
Subject: Assign IP based on if giaddr is even or odd
Message-ID:
        <CAAQ=E+C8G7tLJduJYOhEf4gdie7je4SDwMT=eQJ9pKFRsL1=j...@mail.gmail.com>
Content-Type: text/plain; charset="utf-8"

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-0001.htm>

------------------------------

Message: 2
Date: Wed, 6 Jan 2021 18:04:14 +0000
From: Thor Simon <thor.si...@twosigma.com>
To: Users of ISC DHCP <dhcp-users@lists.isc.org>
Subject: RE: Assign IP based on if giaddr is even or odd
Message-ID:
        <b432abe45aef4be5aa4e5761522e5...@exmbdft10.ad.twosigma.com>
Content-Type: text/plain; charset="utf-8"

You could easily enough do this with a funky ?netmask? (the mask that picks out 
the ?even Internet? from the ?odd Internet? used to be a favorite puzzler 
question of mine) but ISC DHCP, like much other software these past 30 years, 
may not support that.

From: dhcp-users <dhcp-users-boun...@lists.isc.org> On Behalf Of Stephen Donovan
Sent: Wednesday, January 6, 2021 12:54 PM
To: dhcp-users@lists.isc.org
Subject: Assign IP based on if giaddr is even or odd

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/61af318f/attachment-0001.htm>

------------------------------

Subject: Digest Footer

_______________________________________________
ISC funds the development of this software with paid support subscriptions. 
Contact us at https://www.isc.org/contact/ for more information.

dhcp-users mailing list
dhcp-users@lists.isc.org
https://lists.isc.org/mailman/listinfo/dhcp-users


------------------------------

End of dhcp-users Digest, Vol 147, Issue 6
******************************************

Reply via email to