LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   ISC DHCP - class matching based on mac address (https://www.linuxquestions.org/questions/linux-networking-3/isc-dhcp-class-matching-based-on-mac-address-825866/)

sinthetic 08-12-2010 02:28 PM

ISC DHCP - class matching based on mac address
 
We have a large number of devices on our LAN with the mac prefix of 00:60:60. We want to assign these addresses from a separate address pool. I've created two classes, one to match 00:60:60 and another that I want to contain any other device. When i try to start the server I get:

/etc/dhcp3/dhcpd.conf line 33: boolean expression expected
match if not binary-to-ascii(16,8,":",substring(hardware, 1, 3))
^#this carrot should be under the last parenthesis#
Configuration file errors encountered -- exiting


Here is the relevant section of /etc/dhcp3/dhcpd.conf

class "006060" {
match if binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "00:60:60";
}

class "other" {
match if not binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "00:60:60";
}

subnet 10.10.0.0 netmask 255.255.0.0 {
option routers 10.10.100.2;
pool {
allow members of "006060";
range 10.10.250.0 10.10.255.254;
}
pool {
allow members of "other";
range 10.10.0.1 10.10.249.255;
}
}

I've tried a few variations on that line. I've spent days trying to find any examples of "match if not" and haven't found anything. I assume it's going to be something to do with parenthesis/quote placement. Any Ideas? Oh and this is ISC DHCP Server V3.0.4.

Thanks

markf2 08-13-2010 12:58 PM

It looks like the test is backward
 
Not sure but by logic shouldn't you convert the binary-to-ascii first and then substring out the result.

Post you results when you get it working, I need to do the same test.

sinthetic 08-16-2010 11:06 AM

Ok I changed the line to:

match if not(binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "00:60:60");

and the server will start now, but all leases are coming from the "other" pool.

I have tried

match if binary-to-ascii(16,8,":",substring(hardware, 1, 3)) = "00:60:60";
and
match if substring(hardware, 1, 3) = 00:60:60;

Does anyone know of a way to add print statements? Something like:

print "substring(hardware, 1, 3)" > /var/log/dhcp_debug.log

Thanks

sinthetic 08-17-2010 11:48 AM

I got it :D Here is the working config.

class "006060" {
match if binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:60:60";
}

class "other" {
match if not(binary-to-ascii (16,8,":",substring(hardware, 0, 4)) = "1:0:60:60");
}

subnet 10.10.0.0 netmask 255.255.0.0 {
option routers 10.10.100.2;
pool {
allow members of "006060";
range 10.10.250.0 10.10.255.254;
}
pool {
allow members of "other";
range 10.10.0.1 10.10.249.255;
}
}

The "1" at the front of the hardware string signifies ethernet.


All times are GMT -5. The time now is 08:14 PM.