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

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;
                deny members of "phones";
                allow members of "other";
                next-server 192.168.1.251;
                filename "tftpboot/pxelinux.0";
        }
        pool {
                range 192.168.1.120 192.168.1.129;
                allow members of "phones";
                deny members of "other";
                next-server 192.168.1.250;
                option tftp-server-name "http://192.168.1.250/phset.php?mac={mac}";
                server-name "http://192.168.1.250";
                filename "phset.php?mac={mac}";
        }
}

The "1" as the first octet of the MAC address for the phones designates Ethernet as the medium, so it's not truly part of the MAC. The 0:4:13 matches to the 00:04:13 that SNOM uses for their phones, for instance.


Post new comment

The content of this field is kept private and will not be shown publicly. If you have a Gravatar account associated with the e-mail address you provide, it will be used to display your avatar.
  • Web page addresses and e-mail addresses turn into links automatically.
  • Allowed HTML tags: <a> <em> <strong> <cite> <code> <ul> <ol> <li> <dl> <dt> <dd> <br> <p>
  • Lines and paragraphs break automatically.

More information about formatting options

CAPTCHA
This question is for preventing automated spam submissions. It is case sensitive.
Image CAPTCHA
Enter the characters shown in the image.