在IPV6中,地址分配的兩種方式:
1、無狀態自動配置
2、DHCPv6
1、無狀態自動配置
R1(config)#interface f0/0
R1(config-if)#ipv6 enable
R1(config-if)#ipv6 address 2012::1/64
#R2打開debug功能
R2#debug ipv6 icmp
R2#debug ipv6 nd
#R2端口配置
R2(config)#interface fastEthernet 1/0
R2(config-if)#ipv6 enable
R2(config-if)#ipv6 address autoconfig #無狀態自動配置
R2#show ipv6 interface brief
FastEthernet1/0 [up/up]
FE80::CE01:28FF:FE94:10
2012::CE01:28FF:FE94:10 #可以看到f1/0獲取到的地址前綴就是R1 f0/0的地址前綴
在配置了ipv6 address autoconfig后,看R2現在的路由信息,沒有默認路由
R2#show ipv6 route
C 2012::/64 [0/0]
via ::, FastEthernet1/0
L 2012::CE01:28FF:FE94:10/128 [0/0]
via ::, FastEthernet1/0
L FE80::/10 [0/0]
via ::, Null0
L FF00::/8 [0/0]
via ::, Null0
如果配置的是ipv6 address autoconfig default 看R2現在的路由信息,有默認路由,R2會把R1的f0/0作為網關
R2#show ipv6 route
S ::/0 [1/0]
via FE80::CE00:28FF:FE94:0, FastEthernet1/0 #自動添加了靜態默認路由
C 2012::/64 [0/0]
via ::, FastEthernet1/0
L 2012::CE01:28FF:FE94:10/128 [0/0]
via ::, FastEthernet1/0
L FE80::/10 [0/0]
via ::, Null0
L FF00::/8 [0/0]
via ::, Null0
2、DHCPv6
R1配置:
1、先配置本地地址池
2、創建DHCPv6地址池並綁定本地地址池
3、接口應用DHCPv6地址池
ipv6 local pool v6pool 2012::/64 64
ipv6 dhcp pool DHCP-pool
prefix-delegation pool v6pool
dns-server 2000::8
domain-name dantothefourth.com
interface FastEthernet0/0
ipv6 address 2012::1/64
ipv6 enable
ipv6 nd managed-config-flag #將M位置1,通過DHCP方式獲取地址
ipv6 nd other-config-flag #將O位置1,通過DHCP方式獲取其他信息,如DNS
ipv6 dhcp server DHCP-pool
R2的配置:
debug ipv6 dhcp
interface fastEthernet 1/0
ipv6 enable
ipv6 dhcp client pd test #R2通過DHCP獲取到的地址前綴將和test綁定
R2(config-if)#ipv6 address test ::2/64
R2(config-if)#no shutdown
以下為抓包記錄:
R2#show ipv6 interface brief
FastEthernet1/0 [up/up]
FE80::CE05:28FF:FE94:10
2012::2
2.1 DHCP-PD
總部規划給分部的地址段是2019::/64,分部1/0通過無狀態自動配置獲取端口地址,同時獲取DHCP地址段,但只給后面的PC使用
R1配置:
R1(config)#ipv6 unicast-routing
R1(config)#ipv6 local pool ipv6-pool 2019::/64 64
R1(config)#ipv6 dhcp pool dhcp-pool
R1(config-dhcp)#prefix-delegation pool ipv6-pool
R1(config-dhcp)#dns-server 2008::8
R1(config-dhcp)#domain-name dantothefourth.com
R1(config)#interface fastEthernet 0/0
R1(config-if)#ipv6 enable
R1(config-if)#ipv6 address 2012::1/64
R1(config-if)#ipv6 dhcp server dhcp-pool
R2配置:
R2(config)#ipv6 unicast-routing
R2(config)#interface fastEthernet 1/0
R2(config-if)#ipv6 address autoconfig default
R2(config-if)#ipv6 dhcp client pd test #R2通過R1學到了2019::/64的路由前綴,但是到這里還沒使用
R2(config)#interface fastEthernet 0/0
R2(config-if)#ipv6 enable
R2(config-if)#ipv6 address test ::FFFF/64 #這里使用了從1/0學到的路由前綴並使用了
R2#show ipv6 dhcp interface
FastEthernet1/0 is in client mode
State is OPEN
Renew will be sent in 3d11h
List of known servers:
Reachable via address: FE80::CE00:29FF:FE30:0
DUID: 00030001CC0029300000
Preference: 0
Configuration parameters:
IA PD: IA ID 0x00040001, T1 302400, T2 483840
Prefix: 2019::/64
preferred lifetime 604800, valid lifetime 2592000
expires at Mar 31 2002 12:04 AM (2591781 seconds)
DNS server: 2008::8
Domain name: dantothefourth.com
Prefix name: test
Rapid-Commit: disabled
R3配置:
R3(config)#ipv6 unicast-routing
R3(config)#interface fastEthernet 0/0
R3(config-if)#ipv6 enable
R3(config-if)#ipv6 address autoconfig default #通過R2的0/0,無狀態自動配置地址
R3#show ipv6 interface brief
FastEthernet0/0 [up/up]
FE80::CE02:29FF:FE30:0
2019::CE02:29FF:FE30:0