根据下表配置dhcpv6服务器。

Parameter

IPv6 value

Authoritative for the network segment

Yes

Subnet

fc62:5265:6448:6174::/64

Range of addresses to offer

fc62:5265:6448:6174::20 to fc62:5265:6448:6174::60

DNS server

fc62:5265:6448:6174::b

DNS search domains

pvt.example.net, lab.example.com, example.com

Fixed ipv6 address

fc62:5265:6448:6174::c

3.1 配置固定IPV6时,不使用关联的客户端mac地址,这与IPV4不同;IPV6依赖于客户端DHCP唯一标识符DUID。
默认情况下NetworkManager根据/etc/machine-id中的唯一机器ID计算DUID。如果是在同一磁盘中部署多个系统时,请确保第一次重新生成/etc/machine-id文件,否则,这些系统都会获得相同的机器ID,因此会获得相同的DUID,要生成新的机器ID,请使用以下命令:

[root@serverc <sub>]# rm /etc/machine-id
[root@serverc </sub>]# systemd-machine-id-setup
[root@serverc ~]# systemctl restart NetworkManager

当然可以在客户端系统中强制使用DUID,而不是让NetworkManage计算它。可以使用uuidgen命令,然后重新格式化生成新的字符串。

[root@serverc <sub>]# nmcli connection add con-name dhcp-ipv type ethernet ifname eth1
[root@serverc </sub>]# nmcli connection up dhcp-ipv
[root@serverc <sub>]# uuidgen
7f779f07-3419-4b09-83e6-d9e9d3a75b83
[root@serverc </sub>]# echo 7f779f07-3419-4b09-83e6-d9e9d3a75b83 | \
> sed -e 's/-//g' -e 's/\(..\)/:\1/g' -e 's/^://'
33:f9:76:04:cc:c0:40:82:95:64:dc:45:4d:5a:30:86

然后使用nmcli命令,创建NetworkManager连接时请使用ipv6.dhcp-duid选项。

[root@serverc <sub>]# nmcli connection show | grep eth1
dhcp-ipv 5f87e450-308e-4fab-b706-1bd5964ca10f ethernet eth1
[root@serverc </sub>]# nmcli connection modify dhcp-ipv ipv6.dhcp-duid '33:f9:76:04:cc:c0:40:82:95:64:dc:45:4d:5a:30:86' ipv6.method auto
[root@serverc ~]# nmcli connection up dhcp-ipv

3.2 如下所示,编辑/etc/dhcp/dhcpd6.conf配置文件。最终配置结果如下:

[root@servera <sub>]# cat /etc/dhcp/dhcpd6.conf 
#
# DHCPv6 Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd6.conf.example (注意:还是复制这个例子作为参考)
# see dhcpd.conf(5) man page
#
[root@servera </sub>]# cp /usr/share/doc/dhcp-server/dhcpd6.conf.example /etc/dhcp/dhcpd6.conf
cp: overwrite '/etc/dhcp/dhcpd6.conf'? yes
[root@servera <sub>]#
[root@servera </sub>]# vim /etc/dhcp/dhcpd6.conf
authoritative;

subnet6 fc62:5265:6448:6174::/64 {
range6 fc62:5265:6448:6174::20 fc62:5265:6448:6174::60;
option dhcp6.name-servers fc62:5265:6448:6174::b;
option dhcp6.domain-search "pvt.example.net", "lab.example.com", "example.com";
default-lease-time 600;
max-lease-time 7200;
}

host serverc {
host-identifier option
dhcp6.client-id 33:f9:76:04:cc:c0:40:82:95:64:dc:45:4d:5a:30:86;
fixed-address6 fc62:5265:6448:6174::c;
}

3.2 验证/etc/dhcp/dhcpd6.conf的语法。

root@servera ~]# dhcpd -t -6 -cf /etc/dhcp/dhcpd6.conf

3.3 启动并设置服务自启。

[root@servera ~]# systemctl enable --now dhcpd6

3.4 确认服务正在运行。

[root@servera ~]# systemctl is-active dhcpd6
active

3.5 将dhcpv6服务添加到防火墙规则中。

[root@servera <sub>]# firewall-cmd --add-service=dhcpv6
success
[root@servera </sub>]# firewall-cmd --add-service=dhcpv6 --permanent
success
[root@servera <sub>]# firewall-cmd --reload
success
[root@servera </sub>]# firewall-cmd --list-all | grep service
services: cockpit dhcp dhcpv6 dhcpv6-client ssh