【IT168 专稿】OSPF路由协议是链路状态型路由协议,这里的链路即设备上的接口。链路状态型路由协议基于连接源和目标设备的链路状态作出路由的决定。链路状态是接口及其与邻接网络设备的的关系的描述,接口的信息即链路的信息,也就是链路的状态(信息)。这些信息包括接口的IPv6前缀(prefix)、网络掩码、接口连接的网络(链路)类型、与该接口在同一网络(链路)上的路由器等信息。这些链路状态信息由不同类型的LSA携带,在网络上传播。
路由器把收集到的LSA存储在链路状态数据库中,然后运行SPF算法计算出路由表。链路状态数据库和路由表的本质不同在于:数据库中包含的是完整的链路状态原始数据,而路由表中列出的是到达所有已知目标网络的最短路径的列表。
OSPF协议是为IP协议提供路由功能的路由协议。OSPFv2(OSPF版本2)是支持IPv4的路由协议,为了让OSPF协议支持IPv6,技术人员开发了OSPFv3(OSPF版本3),OSPFv3由RFC2740定义。
OSPFv3与OSPFv2
数据包结构
IPv6 使用的LSA类型
配置OSPFv3
NBMA配置示例
配置OSPFv3认证
NBMA配置示例
拓扑结构如图4-5所示,路由器R1和路由器R2通过帧中继相连。两台路由器都运行在NBMA模式,因此需要手工指定邻居,也需要手工做IPv6地址和DLCI值的映射。手工配置邻居和地址影射都使用邻居的本链路地址。R1使用的DLCI值是110;R2使用的DLCI值是120。
图 4-5 NBMA配置拓扑图
(1)路由器R1的配置列表(只列出相关配置)
hostname router1
!
interface Loopback1
no ip address
ipv6 address 2006:1010:0:2::/64 eui-64
ipv6 ospf 1 area 3
!
interface Loopback2
no ip address
ipv6 address 2006:1010:0:3::/64 eui-64
ipv6 ospf 1 area 3
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address 2006:1010:0:1::/64 eui-64
ipv6 enable
ipv6 ospf 1 area 3
!
interface Serial0/0
no ip address
encapsulation frame-relay IETF
ipv6 enable
ipv6 ospf neighbor FE80::20C:31FF:FEE9:860 priority 9
ipv6 ospf 1 area 0
frame-relay map ipv6 FE80::20C:31FF:FEE9:860 110 IETF
!
ipv6 router ospf 1
router-id 1.1.1.1
在R1上手工指定邻居时使用了优先级(priority)参数,使邻居成为了DR。
(2)路由器R2的配置列表(只列出相关配置)
hostname router2
!
interface Loopback1
no ip address
ipv6 address 2006:1010:0:6::/64 eui-64
ipv6 ospf 1 area 2
!
interface Loopback2
no ip address
ipv6 address 2006:1010:0:7::/64 eui-64
ipv6 ospf 1 area 2
!
interface FastEthernet0/0
no ip address
duplex auto
speed auto
ipv6 address 2006:1010:0:5::/64 eui-64
ipv6 ospf 1 area 2
no keepalive
!
interface Serial0/0
no ip address
encapsulation frame-relay IETF
ipv6 enable
ipv6 ospf neighbor FE80::20E:38FF:FEEE:39A0
ipv6 ospf 1 area 0
frame-relay map ipv6 FE80::20E:38FF:FEEE:39A0 120 IETF
!
ipv6 router ospf 1
router-id 2.2.2.2
(3)下面是路由器R1的邻居数据库:
router1# sh ipv6 ospf neighbor detail
Neighbor 2.2.2.2
In the area 0 via interface Serial0/0
Neighbor: interface-id 5, link-local address FE80::20C:31FF:FEE9:860
Neighbor priority is 1 (configured 9), State is FULL, 12 state changes
DR is 1.1.1.1 BDR is 2.2.2.2
(略)
(4)路由器R2的接口参数
router2#sh ipv6 ospf interface s0/0
Serial0/0 is up, line protocol is up
Link Local Address FE80::20C:31FF:FEE9:860, Interface ID 5
Area 0, Process ID 1, Instance ID 0, Router ID 2.2.2.2
Network Type NON_BROADCAST, Cost: 64
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 2.2.2.2, local address FE80::20C:31FF:FEE9:860
Backup Designated router (ID) 1.1.1.1, local address FE80::20E:38FF:FEEE:39A0
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
Hello due in 00:00:28
Index 1/1/1, flood queue length 0
Next 0x0(0)/0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 2
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 1.1.1.1 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
(5)链路状态数据库
router2#sh ipv6 ospf database
OSPFv3 Router with ID (2.2.2.2) (Process ID 1)
Router Link States (Area 0)
ADV Router Age Seq# Fragment ID Link count Bits
1.1.1.1 159 0x8000000C 0 1 B
2.2.2.2 141 0x8000000A 0 1 B
Net Link States (Area 0)
ADV Router Age Seq# Link ID Rtr count
2.2.2.2 188 0x80000001 5 2 (NBMA链路上的路由器数量)
Inter Area Prefix Link States (Area 0)
ADV Router Age Seq# Prefix
1.1.1.1 380 0x80000002 2006:1010:0:3:20E:38FF:FEEE:39A0/128
1.1.1.1 380 0x80000002 2006:1010:0:2:20E:38FF:FEEE:39A0/128
1.1.1.1 380 0x80000002 2006:1010:0:1::/64
2.2.2.2 989 0x80000001 2006:1010:0:7:20C:31FF:FEE9:860/128
2.2.2.2 989 0x80000001 2006:1010:0:6:20C:31FF:FEE9:860/128
2.2.2.2 124 0x80000004 2006:1010:0:5::/64
Link (Type-8) Link States (Area 0)
ADV Router Age Seq# Link ID Interface
1.1.1.1 386 0x80000002 5 Se0/0
2.2.2.2 1005 0x80000001 5 Se0/0
Router Link States (Area 2)
ADV Router Age Seq# Fragment ID Link count Bits
2.2.2.2 965 0x80000002 0 0 B
Inter Area Prefix Link States (Area 2)
ADV Router Age Seq# Prefix
2.2.2.2 180 0x80000001 2006:1010:0:1::/64
2.2.2.2 180 0x80000001 2006:1010:0:2:20E:38FF:FEEE:39A0/128
2.2.2.2 180 0x80000001 2006:1010:0:3:20E:38FF:FEEE:39A0/128
Link (Type-8) Link States (Area 2)
ADV Router Age Seq# Link ID Interface
2.2.2.2 1005 0x80000001 4 Fa0/0
Intra Area Prefix Link States (Area 2)
ADV Router Age Seq# Link ID Ref-lstype Ref-LSID
2.2.2.2 1005 0x80000001 0 0x2001 0
router2#
(6)类型2 LSA的细节
router2#sh ipv6 ospf database network
OSPFv3 Router with ID (2.2.2.2) (Process ID 1)
Net Link States (Area 0)
LS age: 217
Options: (V6-Bit E-Bit R-bit DC-Bit)
LS Type: Network Links
Link State ID: 5 (Interface ID of Designated Router)
Advertising Router: 2.2.2.2
LS Seq Number: 80000001
Checksum: 0xF8F6
Length: 32
Attached Router: 2.2.2.2
Attached Router: 1.1.1.1
5.4 路由总结
设置路由总结的语法如下:
router(config-rtr)#area area-id range ipv6-prefix / prefix-length [advertise | not-advertise] [cost cost]
l area-id:被总结路由所在的区域号;
l ipv6-prefix / prefix-length:总结后的路由前缀及前缀长度;
l advertise:通告该总结路由;
l not-advertise:不向邻居通告该总结路由;
l cost:为总结路由人为赋的开销值。
例如,上述NBMA的环境中,在路由器R1上对区域3的路由进行总结,把路由的前缀总结到62位长,并赋予该总结路由的开销为99,命令如下:
router1(config-rtr)#area 3 range 2006:1010::/62 cost 99
之后,在路由器R2上观察到的路由表如下:
router2#sh ipv6 route
IPv6 Routing Table - 9 entries
Codes: C - Connected, L - Local, S - Static, R - RIP, B - BGP
U - Per-user Static route
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
OI 2006:1010::/62 [110/163]
via FE80::20E:38FF:FEEE:39A0, Serial0/0
C 2006:1010:0:5::/64 [0/0]
via ::, FastEthernet0/0
L 2006:1010:0:5:20C:31FF:FEE9:860/128 [0/0]
via ::, FastEthernet0/0
C 2006:1010:0:6::/64 [0/0]
via ::, Loopback1
L 2006:1010:0:6:20C:31FF:FEE9:860/128 [0/0]
via ::, Loopback1
C 2006:1010:0:7::/64 [0/0]
via ::, Loopback2
L 2006:1010:0:7:20C:31FF:FEE9:860/128 [0/0]
via ::, Loopback2
L FE80::/10 [0/0]
via ::, Null0
L FF00::/8 [0/0]
via ::, Null0
提示:在R1的路由表中将生成一条如下的路由 —— O 2006:1010::/62 [110/0]
via ::, Null0,目的是为避免环路。