Search code examples
ubuntusubclassmac-addressdhcp

ISC-DHCP-Server IP pool assignment through user class


I have isc-dhcp-server installed on Ubuntu 18.04. I have two subnets configured to be served through two different NIC's:

  • enp7s0: 10.100.0.0/22 (Workstations network)
  • enp8s0: 10.200.0.0/23 (Guest network)

Workstation network is broken down to multiple IP pools to issue IPs to different types of devices.

One of the pools is for the DevOps machines which are all laptops. All machines connect to the network through WiFi. I want to ensure that devices connecting to the network get grouped into appropriate pools.

I know I can create classes and add the mac address of those workstations to the sub-classes of those classes to maintain the IP pools. But I have close to 100-150 laptops and adding all mac addresses is quite a headache. Also the vendors/manufacturers of all devices are quite different.

I wanted to know if there is a means that I can add some kind of flag value on the network adapter itself and set my class to assign the IP pool based on this flag value. Is that even possible?


Solution

  • You can sort clients to classes by mac address (mac router's port)

    set switch-mac = binary-to-ascii(16, 8, ":", substring(option agent.remote-id, 2, 6));
    set cl-mac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
    # log macs
    log(error, concat("cl-mac=",cl-mac,"  switch-mac=",switch-mac," opt=",opt));
    class "sw-2" {
    match if switch-mac="mac:of:port:1";
    }
    class "sw-3" {
    match if switch-mac="mac:of:port:2";
    }
    # and then config your pools
    ...
    allow members of "sw-2";