【IT168 专稿】日前,笔者在工作中发现一个问题,即无法得到正常的OSPF路由。笔者现将OSPF协议排错的过程写下来,希望能与更多的朋友共享。
1、 现象描述
在下图中,两台路由器通过串口连接,在互连接口上运行OSPF协议。RouterA的以太网接口地址为111.111.111.1,且运行了OSPF协议,Router的以太网接口地址为222.222.222.1,也启用了OSPF协议。
RouterA的主要配置如下:
interface Loopback0
ip address 197.7.1.1 255.255.255.255
!
interface FastEthernet0/0
ip address 111.111.111.1 255.255.255.0
ip ospf cost 200
duplex auto
speed auto
!
interface Serial1/0
ip address 100.1.0.1 255.255.0.0
ip ospf network point-to-multipoint
ip ospf cost 200
serial restart-delay 0
!
router ospf 22
router-id 197.7.1.1
log-adjacency-changes
network 100.1.0.1 0.0.0.0 area 0
network 111.111.111.1 0.0.0.0 area 0
neighbor 100.1.0.2 cost 200
Router的主要配置如下:
interface FastEthernet0/0
ip address 222.222.222.1 255.255.255.0
ip ospf cost 200
duplex auto
speed auto
!
interface Serial1/0
ip address 100.1.0.2 255.255.0.0
ip ospf network non-broadcast
ip ospf cost 200
serial restart-delay 0
router ospf 22
router-id 197.7.1.2
log-adjacency-changes
network 100.1.0.2 0.0.0.0 area 0
network 222.222.222.1 0.0.0.0 area 0
neighbor 100.1.0.1 cost 200
故障现象如下:
在RouterA和RouterB上查看路由表,发现相互之间并没有学习到OSPF路由。
2、 显示OSPF信息
分别在两台路由器上查看邻居状态,显示如下:
RouterA#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
197.7.1.2 0 FULL/ - 00:01:38 100.1.0.2 Serial1/0
RouterA#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
197.7.1.1 1 FULL/BDR 00:01:54 100.1.0.1 Serial1/0
然后分别察看路由表,有下列显示:
RouterA#show ip route
100.0.0.0/16 is subnetted, 1 subnets
C 100.1.0.0 is directly connected, Serial1/0
197.7.1.0/32 is subnetted, 1 subnets
C 197.7.1.1 is directly connected, Loopback0
111.0.0.0/24 is subnetted, 1 subnets
C 111.111.111.0 is directly connected, FastEthernet0/0
RouterB#show ip route
C 222.222.222.0/24 is directly connected, FastEthernet0/0
100.0.0.0/16 is subnetted, 1 subnets
C 100.1.0.0 is directly connected, Serial1/0
接下来在来查看两台路由器的接口状态如下:
RouterA#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 111.111.111.1/24, Area 0
Process ID 22, Router ID 197.7.1.1, Network Type BROADCAST, Cost: 200
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 197.7.1.1, Interface address 111.111.111.1
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:09
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 0, maximum is 0
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
Serial1/0 is up, line protocol is up
Internet Address 100.1.0.1/16, Area 0
Process ID 22, Router ID 197.7.1.1, Network Type POINT_TO_MULTIPOINT, Cost: 200
Transmit Delay is 1 sec, State POINT_TO_MULTIPOINT,
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
oob-resync timeout 120
Hello due in 00:00:23
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 197.7.1.2, cost is 200
Suppress hello for 0 neighbor(s)
RouterB#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet Address 222.222.222.1/24, Area 0
Process ID 22, Router ID 197.7.1.2, Network Type BROADCAST, Cost: 200
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 197.7.1.2, Interface address 222.222.222.1
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
oob-resync timeout 40
Hello due in 00:00:07
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 0, maximum is 0
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
Serial1/0 is up, line protocol is up
Internet Address 100.1.0.2/16, Area 0
Process ID 22, Router ID 197.7.1.2, Network Type NON_BROADCAST, Cost: 200
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 197.7.1.2, Interface address 100.1.0.2
Backup Designated router (ID) 197.7.1.1, Interface address 100.1.0.1
Timer intervals configured, Hello 30, Dead 120, Wait 120, Retransmit 5
oob-resync timeout 120
Hello due in 00:00:17
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 197.7.1.1 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
3、原因分析
从查看路由器相应接口配置和状态信息来看,RouterA和Router相连接口的OSPF网络类型并不一致,因此导致路由计算错误,无法得到正常的OSPF路由。
4、处理过程
在RouterA和RouterB上,将相应的端口网络类型改为一致,就可以学习到正常的OSPF路由。改变Router的serial1/0口的网络类型为POINT_TO_MULTIPOINT
改正完成后,我们在来看下两台路由器的路由表:
RouterA#show ip route
O 222.222.222.0/24 [110/400] via 100.1.0.2, 00:00:33, Serial1/0
100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 100.1.0.0/16 is directly connected, Serial1/0
O 100.1.0.2/32 [110/200] via 100.1.0.2, 00:00:33, Serial1/0
111.0.0.0/24 is subnetted, 1 subnets
C 111.111.111.0 is directly connected, FastEthernet0/0
RouterB# show ip route
C 222.222.222.0/24 is directly connected, FastEthernet0/0
100.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
O 100.1.0.1/32 [110/200] via 100.1.0.1, 00:00:31, Serial1/0
C 100.1.0.0/16 is directly connected, Serial1/0
111.0.0.0/24 is subnetted, 1 subnets
O 111.111.111.0 [110/400] via 100.1.0.1, 00:00:31, Serial1/0