DHCP scope for a user class option

dhcpdhcp-serverisc-dhcp

In Linux how can I set a DHCP server configuration which will lease IP addresses from scopes which are defined according to user classes. For example the following configuration leases IP addresses according to the first three octets of mac addresses:

# MODIFY TO MATCH YOUR ENVIRONMENT
class "phones"    { match if substring (hardware,1,3) = 00:11:22; }
class "handhelds" { match if substring (hardware,1,3) = 00:33:44; }

# Common configuration
option domain-name "your.domain.name.here";
option domain-name-servers 192.168.2.2;

shared-network lan {
        # phones
        subnet 192.168.0.0 netmask 255.255.255.0 {
                pool {
                        range 192.168.0.10 192.168.0.254;
                        allow members of "phones";
                }
                option routers 192.168.0.1;
                option subnet-mask 255.255.255.0;
        }

        # handheld devices
        subnet 192.168.1.0 netmask 255.255.255.0 {
                pool {
                        range 192.168.1.10 192.168.1.254;
                        allow members of "handhelds";
                }
                option routers 192.168.1.1;
                option subnet-mask 255.255.255.0;
        }

        # Everything else
        subnet 192.168.2.0 netmask 255.255.255.0 {
                pool {
                        range 192.168.2.10 192.168.2.254;
                        allow unknown-clients;
                }
                option routers 192.168.1.1;
                option subnet-mask 255.255.255.0;
}

I want a functionality similar to this but not for the first three octets of MAC addresses but for the user option class (77) of the DHCP request.

Best Answer

You can use a block like:

class "phones" { 
  match if exists user-class and option user-class = "foobar";
 }

Useful references:

Related Topic