Option 82 Sub-option 5

glenn.satchell at uniq.com.au glenn.satchell at uniq.com.au
Sun Jun 20 07:16:06 UTC 2021



On 2021-06-18 20:37, Simon Hobson wrote:
> Kraishak Mahtha <kraishak.edu at gmail.com> wrote:
>> 
>> Hi All,
>> 
>> I have been trying to understand the option 82 sub option 5 
>> (agent.link-selection) working prototype, I have been searching in the 
>> forums and many of them suggest as below
>> 
>> class "BD-1Net" { match if(binary-to-ascii(10, 8, ".", option 
>> agent.link-selection) = "192.168.1.0"); }
>> 
>>  shared-network BD-1Net
>>  {
>>   subnet 192.168.1.0 netmask 255.255.255.0
>> {
>>   option routers 192.168.1.1;
>>   option subnet-mask 255.255.255.0;
>> pool {
>>  allow members of "BD-1Net";
>>  range 192.168.1.101 192.168.1.110;
>>  }
>>  }
>> }
>> I have a doubt of why to add a shared-network line statement in the 
>> config though it has only one subnet, Is it mandatory to add that 
>> shared-network statement?
>> I tried testing without adding the shared-network statement line and 
>> it works fine, but before I use in my prod I want to know full 
>> details,
> 
> Yes, if there is only one subnet then the shared-network is optional.
> AFAIK in this situation it will provide no additional features.
> 
> BTW - it's not necessary to use binary-to-ascii, you can (I think)
> compare the raw data :
> match if( option agent.link-selection = 0xc0a80100 );
> which is less processing though less readable.
> 
> Simon

According to the dhcp-eval man page, string representation can be one of 
two forms:

     string

          A  string,  enclosed  in quotes, may be specified as a data 
expression, and returns the text between the quotes, encoded in ASCII.  
The backslash ('\') character is treated specially, as in C pro‐
          gramming: '\t' means TAB, '\r' means carriage return, '\n' 
means newline, and '\b' means bell.  Any octal value can be specified 
with '\nnn', where nnn is any positive octal number less than 0400.
          Any hexadecimal value can be specified with '\xnn', where nn is 
any positive hexadecimal number less than or equal to 0xff.

     colon-separated hexadecimal list

          A list of hexadecimal octet values, separated by colons, may be 
specified as a data expression.

In this case you could use this format to compare the raw data:

     match if ( option agent.link-selection = c0:a8:01:00 );

Although I also think "\xc0\xa8\x01\x00" would work but this is 
definitely harder to read :)

Personally,unless you have thousands of things trying to match the 
string, the binary-to-ascii() method you're using seems the easiest to 
read.

regards,
Glenn



More information about the dhcp-users mailing list