dhcp-users Digest, Vol 65, Issue 11

Patrick Trapp ptrapp at nex-tech.com
Thu Mar 20 13:55:50 UTC 2014


Can you provide an example of what you have in mind when you refer to "client-circuitid_class"? It doesn't have to be real for your network, but representative. For example, on my network (which does not use Option 61), we look at portions of the circuit-id provided by our blades. If the first four characters of the circuit-id match a specific code, we know the device is attached to a blade on a particular network. If the final five characters of the circuit-id match a different specific code, we know the device is using a particular vlan on that particular network.

So we have match statements like this:

class "XMPL-Client-L3Relay"
{       match if
        (
                (substring (option agent.circuit-id, 0, 4) = "XMPL")
                and not
                (suffix (option agent.circuit-id, 5) = "vlan7")
        );
}
class "XMPL-Modem-L3Relay"
{       match if
        (
                (substring (option agent.circuit-id, 0, 4) = "XMPL")
                and
                (suffix (option agent.circuit-id, 5) = "vlan7")
        );
}

Then we determine which pool the address should be assigned from based on membership (or lack thereof) in a particular class. I have three pools in each shared network. One for members of class XMPL-Client-L3Relay, one for members of class XMPL-Modem-L3Relay, and one for devices that are members of neither class. It seems like we might be able to work with that model to get what you want. 

In your pseudocode, what do you mean by "if Option 61 value is in the class entry"? What's a valid Option 61 value going to look like for you? Are you using shared networks? Do your three classes here represent all possible combinations of requests (that you care about)?

I'm just trying to draw a complete picture in my head of what you have right now and what you want.

Patrick
________________________________________
From: dhcp-users-bounces+ptrapp=nex-tech.com at lists.isc.org [dhcp-users-bounces+ptrapp=nex-tech.com at lists.isc.org] on behalf of Simon Hobson [dhcp1 at thehobsons.co.uk]
Sent: Thursday, March 20, 2014 6:13 AM
To: Users of ISC DHCP
Subject: Re: dhcp-users Digest, Vol 65, Issue 11

lyndon villas <sox316 at gmail.com> wrote:

>    Here's i want to accomplish:
>
>    1. Check if Option 61 value is in the class entry (ex. client-circuitid_class), If YES, then check if Circuit-id is is the available, if no Circuit-id please assign IP address from IP Pool.
>
>    2. If both Option 61 and Circuit-iD are present, compared it to the class entry (e.g client-circuitid_class). If matches the entry, please assign IP address from IP Pool.
>
>    3. Option 61 is not defined (null) but Circuit-id is available and can be found in the class entry (e.g client-circuitid_class), please assign IP address from IP pool.
>
> I hope this pseudocode helps.


It's not clear and consistent.

1 says "If A and not B, then use A".

2 says "If A and B then use 'it'" - without specifying whether 'it' is A or B !

3 says "If B and not A then use B".

A simpler way of writing it is "if A is present then use A, else if B is present then use B" (or swap A and B round depending on what 'it' is).


You can use "pick-first-value" for this.
If 'it' is A then use "pick-first-value(A,B)", or if 'it' is B then use "pick-first-value(B,A)". So your class selection becomes :

match if pick-first-value(A,B)="some string"



But you also don't specify what you want to match the options against. Are they to match against the same string (eg A or B or both would be the same string), or are they to comapre against different strings (in which case the above won't work).

If you match against different strings (so the test is "A="X" or B = "Y") then I think you need a slightly more complicated selection.
I'm not sure if just doing :
  match if A="X";
  match if B="Y";
will work. If not, then you might have to do something like :
  match if (pick-first-option(A,"")="X") or (pick-first-option(B,""="Y") ;

The reason for the pick-first-option clauses here is that if A or B is not present, then the result of comparing it with anything is unknown - and logical ORing unknown with anything is unknown. So the pick-first-value clauses ensure that if A or B is not present, it's replaced with an empty string so that the OR clause will work.

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


More information about the dhcp-users mailing list