在Linux中,我怎样才能设置一个DHCP服务器configuration,它将根据用户类定义的作用域来租用IP地址。 例如,以下configuration根据前三个八位位组的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; }
我想要一个与此类似的function,但不是MAC地址的前三个八位位组,而是DHCP请求的用户选项类(77)。
您可以使用如下块:
class "phones" { match if exists user-class and option user-class = "foobar"; }
有用的参考:
dhcpd.conf(5)联机帮助页