用户类别选项的 DHCP 范围

用户类别选项的 DHCP 范围

在 Linux 中,如何设置 DHCP 服务器配置,以便从根据用户类别定义的范围中租用 IP 地址。例如,以下配置根据 mac 地址的前三个八位字节租用 IP 地址:

# 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;
}

我想要一个类似的功能,但不是针对 MAC 地址的前三个八位字节,而是针对 DHCP 请求的用户选项类 (77)。

答案1

您可以使用如下块:

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

有用的参考资料:

相关内容