Setup IPv6 DHCP Server on CentOS7

首先設定一組IPv6 IP在要處理DHCP的網卡上:


設定完後記得重新啟動網卡,並確認有正確配置。

[root@localhost ~]# ifconfig eno2
eno2: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 10.68.0.6  netmask 255.255.255.0  broadcast 10.68.0.255
        inet6 fe80::1e62:126a:5e95:ff1e  prefixlen 64  scopeid 0x20<link>
        inet6 fc00::1  prefixlen 7  scopeid 0x0<global>
        ether 00:25:90:4b:6c:3f  txqueuelen 1000  (Ethernet)
        RX packets 520773  bytes 778706143 (742.6 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 61432  bytes 4300571 (4.1 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
        device memory 0xfb900000-fb91ffff

Install DHCP server:

yum install dhcp
修改IPv6 dhcp設定(/etc/dhcp/dhcpd6.conf),加入以下內容:
default-lease-time 2592000;
preferred-lifetime 604800;
option dhcp-renewal-time 3600;
option dhcp-rebinding-time 7200;
allow leasequery;
option dhcp6.info-refresh-time 21600;
dhcpv6-lease-file-name "/var/lib/dhcpd/dhcpd6.leases";
 
subnet6 fc00::/7 {
range6 fc00:0:0:0:0:0:0:10 fc00:0:0:0:0:0:0:1000;
}
重新啟動services:
systemctl restart dhcpd6.service
如果啟動有發生問題,請下systemctl status dhcpd6.service去看錯誤原因。

DHCP Client我以CentOS6.8為範例,首先將設定網卡為Automatic, DHCP only:


接著重新啟動網卡確認IP:

[root@localhost ~]# ifconfig eth1 down
[root@localhost ~]# ifconfig eth1 up
[root@localhost ~]# ifconfig eth1
eth1      Link encap:Ethernet  HWaddr 00:25:90:FB:C3:7F
          inet addr:10.68.0.1  Bcast:10.68.0.255  Mask:255.255.255.0
          inet6 addr: fc00::1000/64 Scope:Global
          inet6 addr: fe80::225:90ff:fefb:c37f/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:547 errors:0 dropped:0 overruns:0 frame:0
          TX packets:381 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:119818 (117.0 KiB)  TX bytes:70964 (69.3 KiB)
          Memory:fb100000-fb17ffff
最後檢查路由表:
[root@localhost ~]# route -A inet6 | grep fc00
fc00::1/128                                 fc00::1                                 UC    0      3        0 eth1
fc00::/64                                   *                                       U     256    0        0 eth1
fc00::1000/128                              *                                       U     0      4        1 lo
在CentOS6的情況下,你不需要額外做什麼事情,路由表就會設定完成;但如果在CentOS7上使用了DHCP only,在沒有與RA的互動下,路由表你就要自己來了。DHCP only相關的討論可以參考: