PXE boot SmartOS based on MAC address

It is often useful to be able to boot a select population of your servers to specific OSes or releases. In this article I explain how to use ISC DHCP to select which hosts you want SmartOS to run on based on their MAC addresses.

This is a companion to PXE Booting SmartOS from Ubuntu 12.04.1 LTS. It provides an additional technique for filtering which hosts get SmartOS by MAC address.

Using the class, subclass and allow members of expressions in ISC DHCP allows us to filter on MAC address. It allows a lot more than that, but selection based on MAC address is the main concern of this article.

If a class is defined to extract the hardware address, subclasses can be defined by subclass "classname" 1:mac-address;. The prefix 1: means we are selecting only Ethernet hardware.  Without it, this will not work correctly.  Bear in mind that only colon (:) is accepted as a MAC address delimiter.

Define a smartos class and make it match MAC addresses:

class "smartos" {
  match pick-first-value (option dhcp-client-identifier, hardware);
}

Make the Dell Precision T3500 a member of smartos:

subclass "smartos" 1:b8:ac:6f:8f:3e:1b;

Only apply the IP config and chainload to members of smartos:

allow members of "smartos";

Here is the modified /etc/dhcp/dhcpd.conf with the MAC-based selection of SmartOS hosts:

# /etc/dhcp/dhcpd.conf
ddns-update-style none;
option domain-name "example.com";
option domain-name-servers 208.67.222.222, 208.67.220.220;
default-lease-time 600;
max-lease-time 7200;
log-facility local7;

# define a "smartos" class and make it match MAC addresses
class "smartos" {
  match pick-first-value (option dhcp-client-identifier, hardware);
}

# make the Dell Precision T3500 a member of the "smartos" class
subclass "smartos" 1:b8:ac:6f:8f:3e:1b;

subnet 192.168.2.0 netmask 255.255.255.0 {
  pool {
    # only apply this IP config and chainload to members of "smartos"
    allow members of "smartos";

    range 192.168.2.100 192.168.2.200;
    next-server 192.168.2.34;
    if exists user-class and option user-class = "iPXE" {
      filename = "smartos.ipxe";
    } else {
      filename = "undionly.kpxe";
    }
  }
}

This gives you the ability to selectively deploy SmartOS. It can very easily be used to deploy whatever mix of OSes you may need on bare metal as well.  Dell typically provides the MAC addresses of the NICs on their services with the packing slips.  This is extremely useful when you need to provision gear that a data center provider is racking up for you.

Thanks

Stephan Peijnik deserves my thanks for his article ISC dhcpd and IP assignments from a pool to specific hosts only : tech & sp which showed me this was possible and the mechanics involved.

Thank you also to the fine folks of ISC who release and maintain the carrier-grade ISC DHCP as Open Source so that we all benefit.