Making use of classes
Jeff Haran
jharan at Brocade.COM
Sat Jan 17 02:45:05 UTC 2009
> -----Original Message-----
> From: dhcp-users-bounces at lists.isc.org
> [mailto:dhcp-users-bounces at lists.isc.org] On Behalf Of Gustaf Ankarloo
> Sent: Friday, January 16, 2009 5:17 PM
> To: dhcp-users at lists.isc.org
> Subject: Making use of classes
>
> Im trying to figure out how the [match if substring (option
> dhcp-client-identifier, x, x) = "somevalue"]
> Works inside a class statement.
>
> I´v googled a lot and I see different numbers presented by the x
> How do I know what to put there.
>
> I used dhcpdump and got the following:
> TIME: 2009-01-17 02:04:36.592
> IP: 10.0.0.254 (0:6:b1:1e:cb:e8) > 192.168.32.2 (0:b:cd:73:c0:a5)
> OP: 1 (BOOTPREQUEST)
> HTYPE: 1 (Ethernet)
> HLEN: 6
> HOPS: 0
> XID: c36a3b9b
> SECS: 0
> FLAGS: 0
> CIADDR: 10.0.2.1
> YIADDR: 0.0.0.0
> SIADDR: 0.0.0.0
> GIADDR: 10.0.0.254
> CHADDR: 00:0f:b0:6e:9d:46:00:00:00:00:00:00:00:00:00:00
> SNAME: .
> FNAME: .
> OPTION: 53 ( 1) DHCP message type 3 (DHCPREQUEST)
> OPTION: 61 ( 7) Client-identifier 01:00:0f:b0:6e:9d:46
> OPTION: 12 ( 12) Host name karins-lilla
> OPTION: 81 ( 16) Client FQDN 0-0-0 karins-lilla.
> OPTION: 60 ( 8) Vendor class identifier MSFT 5.0
> OPTION: 55 ( 11) Parameter Request List 1 (Subnet mask)
> 15 (Domainname)
> 3 (Routers)
> 6 (DNS server)
> 44 (NetBIOS name server)
> 46 (NetBIOS node type)
> 47 (NetBIOS scope)
> 31 (Perform
> router discovery)
> 33 (Static route)
> 249 (MSFT -
> Classless route)
> 43 (Vendor specific info)
>
> OPTION: 43 ( 3) Vendor specific info dc0100 ...
>
> My first guess were that for example if I wanted to match by
> hostname OPTION:12 (12) Host name
>
> The config should look like:
> class "test1" {
> match if substring (option host-name, 12, 12) =
> "karins-lilla";
> }
>
> I have tried different variations of dhcp-client-identifier
> instead but to no avail.
>
> What I´m trying to do is divide clients based on some value
> but preferable not MAC into
> different classes. And every class has it´s own range.
>
> Here is the dhcpd.conf:
>
> ddns-update-style interim;
> ddns-updates off;
> authoritative;
> allow client-updates;
> one-lease-per-client false;
> deny bootp;
> option T150 code 150 = string;
> #option local-option97 code97 = string;
>
> class "test1" {
> match if substring (option host-name, 12, 12) =
> "karins-lilla";
>
> }
>
> class "test2" {
> match if substring (option dhcp-client-identifier, 1,
> 12) = "karins-lilla";
>
> }
>
> class "test3" {
> match if substring (option dhcp-client-identifier, 0,
> 12) = "karins-lilla";
>
>
> }
>
> subnet 192.168.32.0 netmask 255.255.255.0 {
> range 192.168.32.4 192.168.32.254;
> option routers 192.168.32.1;
> option domain-name-servers 195.67.199.27,
> 195.67.199.28, 195.67.199.29;
> option domain-name "alphacube.local";
> }
>
> subnet 192.168.168.0 netmask 255.255.255.0 {
> }
>
> subnet 10.0.0.0 netmask 255.255.0.0 {
> pool {
> range 10.0.2.1 10.0.2.254;
> option domain-name "country1.example.org";
> allow members of "test1";
> }
> pool {
> range 10.0.3.1 10.0.3.254;
> option domain-name "country2.example.org";
> allow members of "test2";
> }
> pool {
> range 10.0.4.1 10.0.4.254;
> option domain-name "country3.example.org";
> allow members of "test3";
> }
> # range 10.0.1.1 10.0.1.254;
> option routers 10.0.0.254;
> option domain-name-servers 195.67.199.27,
> 195.67.199.28, 195.67.199.29;
> }
>
> host gustaf-laptop {
> hardware ethernet 00:1f:29:b0:12:cd;
> fixed-address 192.168.32.3;
> }
>
>
> Possibly there is some major config fault from me.
>
> I´d appreciate any input
>
> > Gustaf Ankarloo
> Systemtekniker
> --------------------------------------------------------------
> ----------------------------------------------------------------
>
> Tel. dir.: +46 31 26 04 80
> Mob.: +46 708 14 70 95
> Fax.:+46 31 26 41 40
> www.nestil.se
> --------------------------------------------------------------
> ----------------------------------------------------------------
> This e-mail may contain confidential and/or legally
> privileged information.
> If you are not the intended recipient (or have received this
> e-mail in error) please
> notify the sender immediately and delete this e-mail.
> Any unauthorized copying, disclosure or distribution of the
> material in this e-mail is strictly forbidden.
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users
>
>From the dhcp-eval man page:
substring (data-expr, offset, length)
The substring operator evaluates the data expression and returns the
substring of the result of that evaluation that starts offset bytes
from the beginning, continuing for length bytes. Offset and length
are both numeric expressions. If data-expr, offset or length evalu-
ate to null, then the result is also null. If offset is greater
than or equal to the length of the evaluated data, then a zero-
length data string is returned. If length is greater then the
remaining length of the evaluated data after offset, then a data
string containing all data from offset to the end of the evaluated
data is returned.
The second parameter to substring isn't the option number, it's the starting byte number in the portion of the option being matched. So class test1 doesn't match because offset isn't right and test2 and test3 don't match because "karins-lilla" isn't contained in the client identifier.
Jeff Haran
Brocade
More information about the dhcp-users
mailing list