DHCP – How to Assign IPs for Specific MAC Prefixes

isc-dhcpmac address

I'm running a ISC DHCPd server for my network serving a number of subnets. One of the things I would like to do is assign a specific range of IPs to hosts with a common MAC prefix (ex. 00:01:02). Also, the assignments have to be able to be over-ridden by assignments with fixed-address. I've googled for it, but haven't found anything definitive.

Bonus if I can put the statement within a subnet stanza of my dhcpd.conf (it would fit better with my management software).

Best Answer

On my system (debian lenny), I need to need binary-to-ascii in order to match mac-addresses. In this (working) example from my dhcpd.conf, server247 is in class "local", however, I give it a fixed address that it not in the pool. I would recommend that the fixed addresses be in a separate range from the dynamically assigned addresses (they can still be in the same subnet).

class "kvm" {
   match if binary-to-ascii(16,8,":",substring(hardware, 1, 2)) = "56:11";
}

class "local" {
   match if binary-to-ascii(16,8,":",substring(hardware, 1, 2)) = "52:54";
}

host meme {
 fixed-address 10.1.0.254;
}

host server247 {
  hardware ethernet 52:54:00:2f:ea:07;
  fixed-address 10.1.0.247;
}

subnet 10.1.0.224 netmask 255.255.255.224 {
  option routers 10.1.0.225;
  pool {
     allow members of "kvm";
     range 10.1.0.226 10.1.0.235;
  }
  pool {
     allow members of "local";
     range 10.1.0.236 10.1.0.240;
  }
  pool {
     # Don't use this pool. It is really just a range to reserve
     # for fixed addresses defined per host, above.
     allow known-clients;
     range 10.1.0.241 10.1.0.253;
  }
}

For your example, you would do:

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