简介
本文档介绍 IPv6 链路本地地址在网络中的工作原理。
先决条件
要求
Cisco 建议您了解以下主题:
使用的组件
本文所述的内容基于运行 Cisco IOS® 软件版本 12.4(15)T1 的思科 3700 系列路由器。
本文档中的信息都是基于特定实验室环境中的设备编写的。本文档中使用的所有设备最初均采用原始(默认)配置。如果您的网络处于活动状态,请确保您了解所有命令的潜在影响。
规则
有关文档规则的详细信息,请参阅 Cisco 技术提示规则。
背景信息
本地链路地址是可在使用本地链路前缀FE80::/10 (1111 1110 10)和接口标识符的接口上以修改的EUI-64格式自动配置的IPv6单播地址。本地链路地址不必绑定到MAC地址,但使用EUI-64方法(其中MAC地址嵌入到IPv6地址中)配置本地链路地址是常见的,使用ipv6 address <address> link-local命令,本地链路地址也可以以FE80::/10格式手动配置。
注意:有关EUI-64格式接口标识符的详细信息,请访问IP版本6寻址架构RFC4291
IPv6中的本地链路地址仅用于特定物理链路,这意味着设备之间的本地网络连接。这些地址对于自动地址配置等任务以及邻居发现协议(NDP)至关重要,该协议可帮助同一链路上的设备查找并相互通信。本地链路地址允许相邻节点之间进行通信,而无需全局唯一的地址。重要的是,IPv6路由器不会使用本地网络之外的本地链路地址转发数据。所有启用IPv6的接口自动具有本地链路单播地址。
配置
在此示例中,路由器 R1、R2 和 R3 通过串行接口连接,并配置有网络图中所示的 IPv6 地址。在路由器 R1 和 R3 上配置了环回地址,并且路由器使用 OSPFv3 相互通信。此示例使用 ping 命令演示使用链路本地地址在路由器之间进行连接。路由器R1和R3可以使用IPv6本地单播地址互相ping,但无法使用它们的本地链路地址互相ping。但是,路由器R2直接连接到R1和R3,因此它可以使用它们的本地链路地址与这两台路由器通信,因为本地链路地址仅用于特定于物理接口的本地网络中。
网络图
本文档使用以下网络设置:
使用的配置
本文档使用以下配置:
以下视频演示了 Cisco IOS 路由器中 IPv6 链路本地地址和全局单播地址之间的主要区别:
路由器 R1 |
hostname R1
!
ipv6 cef
!
ipv6 unicast-routing
!
interface Loopback10
no ip address
ipv6 address FD10::/64 eui-64
!--- Assigned a IPv6 unicast address in EUI-64 format.
ipv6 ospf 1 area 1
!--- Enables OSPFv3 on the interface and associates the interface looback10 to area 1.
!
interface Loopback20
no ip address
ipv6 address FD20::/64 eui-64
ipv6 ospf 1 area 2
!--- Associates the Interface loopback20 to area 2.
!
interface Serial0/0
no ip address
ipv6 address 2001::1/124
ipv6 ospf 1 area 0
!--- Associates the Interface serial0/0 to area 0.
clock rate 2000000
!
ipv6 router ospf 1
router-id 10.1.1.1
!--- Router R1 uses 10.1.1.1 as router id.
log-adjacency-changes
!
end |
路由器 R2 |
路由器 R3 |
hostname R2
!
ipv6 cef
!
ipv6 unicast-routing
!
!
!
interface Serial0/0
no ip address
ipv6 address 2001::2/124
ipv6 ospf 1 area 0
clock rate 2000000
!
!
interface Serial0/1
no ip address
ipv6 address 2002::1/124
ipv6 ospf 1 area 0
clock rate 2000000
!
!
!
ipv6 router ospf 1
router-id 10.2.2.2
log-adjacency-changes
!
end |
hostname R3
!
ipv6 cef
!
ipv6 unicast-routing
! ! !
interface Loopback10
no ip address
ipv6 address FD01::/64 eui-64
ipv6 ospf 1 area 1
! !
interface Loopback20
no ip address
ipv6 address FD20::/64 eui-64
ipv6 ospf 1 area 2
! !
interface Serial0/0
no ip address
ipv6 address FE80::AB8 link-local
ipv6 address 2002::2/124
ipv6 ospf 1 area 0
clock rate 2000000
! ! !
ipv6 router ospf 1
router-id 10.3.3.3
log-adjacency-changes
!
end
|
确认
验证 OSPF 配置
要验证是否已正确配置 OSPF,请在 show ipv6 route ospf
命令。
show ipv6 route ospf |
路由器 R1 R1#show ipv6 route ospf
IPv6 Routing Table - 10 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
U - Per-user Static route, M - MIPv6
I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
D - EIGRP, EX - EIGRP external
OI FD01::C002:1DFF:FEE0:0/128 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0
O 2002::/124 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0
OI FD20::C002:1DFF:FEE0:0/128 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0 路由器 R3 R3#show ipv6 route ospf
IPv6 Routing Table - 10 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
U - Per-user Static route, M - MIPv6
I1 - ISIS L1, I2 - ISIS L2, IA - ISIS interarea, IS - ISIS summary
O - OSPF intra, OI - OSPF inter, OE1 - OSPF ext 1, OE2 - OSPF ext 2
ON1 - OSPF NSSA ext 1, ON2 - OSPF NSSA ext 2
D - EIGRP, EX - EIGRP external
O 2001::/124 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0
OI FD10::C000:1DFF:FEE0:0/128 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0
OI FD20::C000:1DFF:FEE0:0/128 [110/128]
via FE80::C001:1DFF:FEE0:0, Serial0/0 |
验证链路本地地址可访问性
各路由器可以使用全局单播地址相互 ping 通。如果路由器只使用链路本地地址,则直连网络可以通信。例如,R1可以使用全局单播地址ping R3,但两台路由器无法使用本地链路地址通信。这可通过在路由器 R1 和 R3 中使用 ping 和 debug ipv6 icmp 命令展示出来。
从远程网络对链路本地地址执行 ping 操作
当路由器R1尝试使用本地链路地址与路由器R3通信时,路由器R1会返回ICMP超时消息,指出本地链路地址是本地特定的,无法与直连网络之外的本地链路地址通信。
从路由器 R1 对 R3 的链路本地地址执行 ping 操作 |
在路由器 R1 中 R1#ping FE80::AB8
Output Interface: serial0/0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to FE80::AB8, timeout is 2 seconds:
Packet sent with a source address of FE80::C000:1DFF:FEE0:0
.....
Success rate is 0 percent (0/5)
!--- Pinging Link-Local Address of router R3.
!--- The ping is unsuccessful and the ICMP packet cannot reach the destination through serial0/0.
!--- This timeout indicates that R1 has not received any replies from the router R3.
|
从直连网络对链路本地地址执行 ping 操作
对于路由器R2,路由器R1和R3直接相连,当它们与连接到路由器的相关接口通信时,它们可以ping路由器R1和R2的本地链路地址。输出如下所示:
从路由器 R2 对 R1 的链路本地地址执行 ping 操作 |
在路由器 R2 中 R2#ping FE80::C000:1DFF:FEE0:0
Output Interface: serial0/0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to FE80::C000:1DFF:FEE0:0, timeout is 2 seconds:
Packet sent with a source address of FE80::C001:1DFF:FEE0:0
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/19/56 ms
!--- Pinging Link-Local Address of router R1, R2 connects to R1 via serial0/0. R1 的调试输出 R1#
*Mar 1 03:59:53.367: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.371: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.423: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.427: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.463: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.463: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.467: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.467: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.471: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 03:59:53.471: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
!--- The debug output shows that the router R2 can ping router R1's Link-Local address.
|
从路由器 R2 对 R3 的链路本地地址执行 ping 操作 |
在路由器 R2 中 R2#ping FE80::AB8
Output Interface: serial0/1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to FE80::AB8, timeout is 2 seconds:
Packet sent with a source address of FE80::C001:1DFF:FEE0:0
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/18/60 ms
!--- Note that, to ping the Link-Local address, output interface is needed. In our case, R2 connects to R3 throught serial0/1. R3 的调试输出 R3#
*Mar 1 04:12:11.518: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.522: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.594: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.598: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.618: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.618: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.622: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.622: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.626: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 04:12:11.630: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
!--- The debug output shows that the router R2 can ping router R3's Link-Local address.
|
链路本地地址只能用于相应的本地网络。各路由器可以具有相同的链路本地地址,并且直连网络仍然可以相互通信,而不会发生任何冲突。如果使用全局单播地址,则情况就不一样了。可路由的全局单播地址在网络中必须是唯一的。show ipv6 interface brief命令显示有关接口上的本地链路地址的信息。
show ipv6 interface brief |
在路由器 R1 中 R1#show ipv6 interface brief
Serial0/0 [up/up]
FE80::AB8
2001::1
Loopback10 [up/up]
FE80::C000:1DFF:FEE0:0
FD10::C000:1DFF:FEE0:0
Loopback20 [up/up]
FE80::C000:1DFF:FEE0:0
FD20::C000:1DFF:FEE0:0 在路由器 R3 中 R3#show ipv6 interface brief
Serial0/0 [up/up]
FE80::AB8
2002::2
Loopback10 [up/up]
FE80::C002:1DFF:FEE0:0
FD01::C002:1DFF:FEE0:0
Loopback20 [up/up]
FE80::C002:1DFF:FEE0:0
FD20::C002:1DFF:FEE0:0
!--- Shows that R1 and R3's serial interface has same Link-Local address FE80::AB8.
|
在本例中,R1和R3被分配了相同的本地链路地址,当它们指定相关输出接口时,R2仍可到达两台路由器。
从 R2 对 R1 和 R3 的链路本地地址执行 ping 操作 |
从 R2 对 R1 的链路本地地址执行 ping 操作 R2#ping FE80::AB8
Output Interface: serial0/0
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to FE80::AB8, timeout is 2 seconds:
Packet sent with a source address of FE80::C001:1DFF:FEE0:0
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/26/92 ms
!--- R2 is connected to R1 through serial0/0. R1 的调试输出 R1#
*Mar 1 19:51:31.855: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.859: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.915: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.919: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.947: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.947: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.955: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.955: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.955: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:51:31.955: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0 从 R2 对 R3 的链路本地地址执行 ping 操作 R2#ping FE80::AB8
Output Interface: serial0/1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to FE80::AB8, timeout is 2 seconds:
Packet sent with a source address of FE80::C001:1DFF:FEE0:0
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 4/28/76 ms
!--- R2 is connected to R1 through serial0/1. R3 的调试输出 R3#
*Mar 1 19:53:38.815: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.819: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.911: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.915: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.923: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.927: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.955: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.955: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.963: ICMPv6: Received echo request from FE80::C001:1DFF:FEE0:0
*Mar 1 19:53:38.963: ICMPv6: Sending echo reply to FE80::C001:1DFF:FEE0:0 |
注意:R2只能ping通R1和R3的本地链路地址,因为它们直接相连。R2无法ping通路由器R1和R3中环回接口的本地链路地址,因为它们不是直接连接的。仅在直连网络中可以 ping 通链路本地地址。
注意:对于本地链路地址,跟踪路由不起作用,并返回“% No valid source address for destination”(没有有效的目标源地址)错误消息。这是因为IPv6路由器不能将具有本地链路源地址或目的地址的数据包转发到其他链路。
相关信息