Tony's ramblings on Open Source Software, Life and Photography

dhcp3-server dhcp3 dhcp mac linux

Serving DHCP Based on MAC Prefixes with DHCP3

I suddenly found myself needing a separate TFTP boot system for various devices on my network. We utilize a TFTP / PXEBoot installation system for deploying computers.

We also use Vo/IP phones. Mostly the Vo/IP phones are on their own physical network, but there's a few places that isn't practical, so those phones are connected to the regular network. For easy deployment of phones, we provide all of their settings with a combination of a web service and a TFTP configuration pointer from DHCP. That conflicts with the other TFTP settings for desktops.

After a bit of research, I finally figured out how to provide a separate DHCP group within our subnet based on a partial MAC address match - allowing me to choose the phone vendor's MAC prefix as a filter for those devices.

Here's an example file:

ddns-update-style none;
default-lease-time 432000;
max-lease-time 432000;
authoritative;
log-facility local7;

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

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

# subnet
subnet 192.168.1.0 netmask 255.255.255.0 {
        option routers 192.168.1.254;
        option domain-name-servers 192.168.1.8, 192.168.1.9;
        pool {
                range dynamic-bootp 192.168.1.150 192.168.1.199;