3.11. 使用 group 声明同时将参数应用到多个主机、子网和共享网络
使用 group 声明,您可以将同样的参数应用到多个主机、子网和共享网络。
请注意,流程描述了对主机使用 group 声明,但步骤与子网和共享网络的相同。
根据您要为 IPv4、IPv6 或两个协议配置组,请查看以下操作过程:
先决条件
-
dhcpd服务已配置且正在运行。 -
已以
root用户身份登录。
步骤
对于 IPv4 网络:
编辑
/etc/dhcp/dhcpd.conf文件:添加一个
group声明:group { option domain-name-servers 192.0.2.1; host server1.example.com { hardware ethernet 52:54:00:72:2f:6e; fixed-address 192.0.2.130; } host server2.example.com { hardware ethernet 52:54:00:1b:f3:cf; fixed-address 192.0.2.140; } }group { option domain-name-servers 192.0.2.1; host server1.example.com { hardware ethernet 52:54:00:72:2f:6e; fixed-address 192.0.2.130; } host server2.example.com { hardware ethernet 52:54:00:1b:f3:cf; fixed-address 192.0.2.140; } }Copy to Clipboard Copied! Toggle word wrap Toggle overflow 这个
group定义对两个host条目进行分组。dhcpd服务将option domain-name-servers参数中设置的值应用到组中的两个主机。-
可选:在这些主机的
group声明中添加其他设置。
重启
dhcpd服务:systemctl start dhcpd
# systemctl start dhcpdCopy to Clipboard Copied! Toggle word wrap Toggle overflow
对于 IPv6 网络:
编辑
/etc/dhcp/dhcpd6.conf文件:添加一个
group声明:group { option dhcp6.domain-search "example.com"; host server1.example.com { hardware ethernet 52:54:00:72:2f:6e; fixed-address 2001:db8:0:1::200; } host server2.example.com { hardware ethernet 52:54:00:1b:f3:cf; fixed-address 2001:db8:0:1::ba3; } }group { option dhcp6.domain-search "example.com"; host server1.example.com { hardware ethernet 52:54:00:72:2f:6e; fixed-address 2001:db8:0:1::200; } host server2.example.com { hardware ethernet 52:54:00:1b:f3:cf; fixed-address 2001:db8:0:1::ba3; } }Copy to Clipboard Copied! Toggle word wrap Toggle overflow 这个
group定义对两个host条目进行分组。dhcpd服务将option dhcp6.domain-search参数中设置的值应用到组中的两个主机。-
可选:在这些主机的
group声明中添加其他设置。
重启
dhcpd6服务:systemctl start dhcpd6
# systemctl start dhcpd6Copy to Clipboard Copied! Toggle word wrap Toggle overflow