【IPV6 地址分配的两种方式】
在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