How to match part of agent's vendor specific suboption

Glenn Satchell glenn.satchell at uniq.com.au
Mon Oct 10 12:16:26 UTC 2011


ok, so you still need to say "option agent ...".

However, you can define your own option space where you specify the 
sub-options and dhcpd will unpack them for you. See the dhcp-options man 
page under "ENCAPSULATION". This will look at option numbers and string 
length, so it will work in a much more generic way, eg your assumption 
that the length of the string is always 5, and previous options always 
finish before position 60.

It will be something like this (note I haven't tested this so it might 
need some adjustments). In the second line, code 9 refers to the 
sub-option code number. In the third line code 82 refers to the 
encapsulated option number.

      option space my-agent;
      # decode as many sub-options here as required, one per line
      option my-agent.ssid code 9 = text;

      # encapsulate these in one option
      option my-agent-encapsulate code 82 = encapsulate local;

      # use it like this
      match if (option my-agent.ssid = "SSID1");

regards,
-glenn

On 10/10/11 22:36, Eduardo Ferreira Juca de Castro wrote:
> Thanks Glenn,
>
> But I need to match a vendor specific suboption. The ones you listed
> isn't in the packet.
> I'll handle just one vendor dhcp relay though, so I know the order the
> suboptions are packed.
> If I can't use the global agent how to get access to the vendor specific
> suboptions?
>
> []
> Eduardo F. Jucá de Castro
> CPqD - Gerência de Serviços e Aplicações Multimídia
> Tel.: +55 19 3705-7238 / Fax: +55 19 3705-5868
> Cel.: +55 19 9603-4624
> jucah at cpqd.com.br <mailto:jucah at cpqd.com.br>
> www.cpqd.com.br <http://www.cpqd.com.br>
>
>
>
> 2011/10/9 Glenn Satchell <glenn.satchell at uniq.com.au
> <mailto:glenn.satchell at uniq.com.au>>
>
>     See man dhcp-options, I think you need to specify one of
>
>     option agent.circuit-id
>     option agent.remote-id
>     option agent.DOCSIS-device-class
>     option agent.link-selection
>
>     You definitely need the "option" key word, otherwise it uses a variable
>     named "agent" which is probably null.
>
>     Using substring on the whole agent field may not extract it
>     correctly, as
>     the order of packing in the sub options could vary.
>
>     regards,
>     -glenn
>
>      > I'm using a similar statement to match PXE clients (to
>     differentiate from
>      > when installed systems boot - the PXE boot rom sends a specific
>     client
>      > option, and we had out different settings to these clients...
>     works on
>      > dhcp 3.0.x and 4.2.x (tested) - seems similar to what you want,
>     it might
>      > help.. here's the config block (actual IP replaced with 1.2.3.4
>     in this
>      > example):
>      >
>      >
>      >
>      > class "PXE" {
>      >         match if substring(option vendor-class-identifier, 0, 9) =
>      > "PXEClient";
>      >         filename "pxelinux.0"
>      >         option vendor-class-identifier "PXEClient";
>      >         vendor-option-space PXE;
>      >         option PXE.mtftp-ip 0.0.0.0;
>      >         next-server 1.2.3.4;
>      > }
>      >
>      > sounds like you might need the 'option' keyword before 'agent' to
>     match
>      > what you're looking for?
>      >
>      >
>      >
>      > ====================
>      >
>      > Scott Stone <scott_stone at trendmicro.com
>     <mailto:scott_stone at trendmicro.com>>
>      > Manager, DCS-RD
>      > Trend Micro, Inc. http://www.trendmicro.com
>      >
>      >
>      >
>      > From: dhcp-users-bounces+scott_stone=trendmicro.com at lists.isc.org
>     <mailto:trendmicro.com at lists.isc.org>
>      > [mailto:dhcp-users-bounces+scott_stone
>     <mailto:dhcp-users-bounces%2Bscott_stone>=trendmicro.com at lists.isc.org
>     <mailto:trendmicro.com at lists.isc.org>] On
>      > Behalf Of Eduardo Ferreira Juca de Castro
>      > Sent: Sunday, October 09, 2011 12:07 PM
>      > To: dhcp-users at lists.isc.org <mailto:dhcp-users at lists.isc.org>
>      > Subject: How to match part of agent's vendor specific suboption
>      >
>      >
>      >
>      > Hi,
>      >
>      >
>      >
>      > I need to assign addresses based on a ssid information carried on
>     agent's
>      > (option 82) vendor specific suboption.
>      >
>      > Do do so I defined classes this way:
>      >
>      > class "myClass" {
>      >     match if substring(agent,60,5) = "SSID1";
>      > }
>      >
>      > and used it in pool statements but nothing happens.
>      >
>      > I also tried to log things to see waht are beeing decoded but again
>      > nothing happens.
>      >
>      > if option dhcp-message-type = 1 {
>      >
>      >     log(info,concat("option82-suboption9:
>      > ",binary-to-ascii(16,8,"",substring(agent,60,5))));
>      >
>      > }
>      >
>      >
>      >
>      > I'm using ISC DHCP 4.2.1.
>      >
>      > Anyone can help me with this?
>      >
>      >
>      >
>      > TIA
>      >
>      >
>      >
>      > Regards,
>      >
>      >
>      >
>      >
>      > Eduardo F. J. de Castro
>      >
>      > CPqD - Telecommunications and IT R&D Center
>      >
>      >



More information about the dhcp-users mailing list