DHCPv6

配置DHCPv6地址

如下表所示配置DHCPv6服务器。

ParameterIPv6 value
Authoritative for the network segmentYes
Subnetfc62:5265:6448:6174::/64
Range of addresses to offerfc62:5265:6448:6174::20 to fc62:5265:6448:6174::60
DNS serverfc62:5265:6448:6174::b
DNS search domainspvt.example.net, lab.example.com, example.com
Fixed ipv6 addressfc62: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 ~]# rm /etc/machine-id
[root@serverc ~]# systemd-machine-id-setup
[root@serverc ~]# systemctl restart NetworkManager

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

[root@serverc ~]# nmcli connection add con-name dhcp-ipv type ethernet ifname eth1
[root@serverc ~]# nmcli connection up dhcp-ipv
[root@serverc ~]# uuidgen
7f779f07-3419-4b09-83e6-d9e9d3a75b83
[root@serverc ~]# 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 ~]# nmcli connection show | grep eth1
dhcp-ipv            5f87e450-308e-4fab-b706-1bd5964ca10f  ethernet  eth1 
[root@serverc ~]# 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 ~]# 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 ~]# cp /usr/share/doc/dhcp-server/dhcpd6.conf.example /etc/dhcp/dhcpd6.conf 
cp: overwrite '/etc/dhcp/dhcpd6.conf'? yes
[root@servera ~]#
[root@servera ~]# 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 ~]# firewall-cmd --add-service=dhcpv6
success
[root@servera ~]# firewall-cmd --add-service=dhcpv6 --permanent 
success
[root@servera ~]# firewall-cmd --reload
success
[root@servera ~]# firewall-cmd --list-all | grep service
  services: cockpit dhcp dhcpv6 dhcpv6-client ssh
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值