OSPF路由问题的排查整体思路为:
首先检查OSPF邻居关系,
然后检查OSPF LSDB数据库信息,
最后检查全局路由表.
解决方案
具体排查如下:
查看两端OSPF邻居状态是否正常,正常情况下DRother之间的邻居关系应该稳定在2-way状态,非DRother之间的邻居关系应该稳定在Full状态
命令:display ospf peer x.x.x.x
例如:通过命令查看,可以确认OSPF的邻居状态是否正常。
OSPF Process 1 with Router ID 10.1.4.4
Neighbors
Area 0.0.0.224 interface 10.1.224.4(GigabitEthernet0/0/0)'s neighbors
Router ID: 10.1.222.12 Address: 10.1.224.12
State: Full Mode:Nbr is Master Priority: 1
DR: 10.1.224.12 BDR: 10.1.224.4 MTU: 0
Dead timer due in 35 sec
Retrans timer interval: 5
Neighbor is up for 00:48:58
Authentication Sequence: [ 0 ]
查看OSPF路由表中是否存在相应路由。
命令:display ospf routing x.x.x.x
例如:查看外部路由9.9.9.9是否加入ospf路由表
OSPF Process 1 with Router ID 10.1.4.4
Destination: 10.1.2.2/32
AdverRouter: 10.1.222.12 Tag: 301
Cost : 1 Type: Type2
NextHop : 10.1.224.12 Interface: GigabitEthernet0/0/0
Priority : Medium Age: 00h50m53s
OSPF Process 1 with Router ID 10.1.4.4
Routing Tables
Routing for ASEs
Destination Cost Type Tag NextHop AdvRouter
10.1.2.2/32 1 Type2 301 10.1.224.12 10.1.222.12
OSPF的运行是基于设备接口的,如果OSPF没有在接口启动,那么邻居关系肯定无法形成。在接口上启用OSPF是通过Area视图下的network命令实现的,必须确保network中的网络范围包括需要启动OSPF的接口地址。
命令:display ospf interface
例如:通过命令查看接口是否启动OSPF
OSPF Process 1 with Router ID 10.1.4.4
Interfaces
Area: 0.0.0.0 (MPLS TE not enabled)
IP Address Type State Cost Pri DR BDR
10.1.4.4 P2P P-2-P 0 1 0.0.0.0 0.0.0.0
命令:display ospf error
例如:通过命令查看邻居两端OSPF参数匹配
OSPF Process 1 with Router ID 10.1.4.4
OSPF error statistics
General packet errors:
0 : IP: received my own packet 0 : Bad packet
0 : Bad version 0 : Bad checksum
0 : Bad area id 0 : Drop on unnumbered interface
0 : Bad virtual link 0 : Bad authentication type
0 : Bad authentication key 0 : Packet too small
0 : Packet size > ip length 0 : Transmit error
0 : Interface down 0 : Unknown neighbor
0 : Bad net segment 0 : Extern option mismatch
0 : Router id confusion
HELLO packet errors:
0 : Netmask mismatch 0 : Hello timer mismatch
0 : Dead timer mismatch 0 : Virtual neighbor unknown
0 : NBMA neighbor unknown 0 : Invalid Source Address
DD packet errors:
0 : Neighbor state low 0 : Unknown LSA type
0 : MTU option mismatch
LS ACK packet errors:
0 : Neighbor state low 0 : Unknown LSA type
LS REQ packet errors:
0 : Neighbor state low 0 : Empty request
0 : Bad request
LS UPD packet errors:
0 : Neighbor state low 0 : Newer self-generate LSA
0 : LSA checksum bad 2 : Received less recent LSA
0 : Unknown LSA type
Opaque errors:
0 : 9-out of flooding scope 0 : 10-out of flooding scope
0 : 11-out of flooding scope 0 : Unkown TLV type
Retransmission for packet over Limitation errors:
0 : Number for DD Packet 0 : Number for Update Packet
0 : Number for Request Packet
Receive Grace LSA errors:
0 : Number of invalid LSAs 0 : Number of policy failed LSAs
0 : Number of wrong period LSAs
Configuration errors:
0 : Tunnel cost mistake
反复使用以上命令显示,对应错误数增加则存在问题相应的参数匹配问题。常见几种错误如下:
(1)OSPF区域配置是否匹配
启动OSPF的接口属于某个区域,同时区域有多种类型,区域依靠区域ID进行标识,如果两边的区域类型或区域ID不匹配,则不会形成邻居关系。
(2)OSPF验证配置是否匹配
OSPF支持报文验证功能,验证分为简单验证和MD5验证两种类型,如果两边验证类型或密钥配置不同,则OSPF无法通过验证,邻居关系无法形成。
(3)两端OSPF接口上计时器设定值是否匹配
OSPF通过周期性的交互Hello报文维系邻居关系,Hello报文中携带了Hello报文的发送间隔计时器及邻居失效计时器,如果这些计时器的值在两边的Hello报文中不匹配,那么OSPF的邻居关系无法形成。注意dead timer的值至少应为hello timer值的4倍
(4)两端OSPF接口类型是否匹配
OSPF邻居关系的正常建立需要确保邻居两端接口的OSPF网络类型一致,否则将无法形成邻居关系。需要说明的是若邻居双方一端设置为P2P类型另一端设置为广播类型,那么邻居状态可以达到FULL状态,但此时无法计算出路由信息。
(5)广播网络中两端接口子网掩码是否相同
OSPF Hello报文中携带子网掩码信息。在广播网络中,如果两端接口属于不同的IP子网,那么邻居关系无法形成。
(6)NBMA网络是否指定邻居
OSPF网络类型为NBMA时必须手工指定邻居的IP地址,否则端口无法发送Hello报文,无法形成邻居关系。
命令:display current-configuration interface
display current-configuration configuration ospf
例如:通过命令查看接口下的OSPF参数设置是否一致。
[AR7]display current-configuration interface gigabitethernet0/0/2
#
interface GigabitEthernet0/0/2
ip address 100.1.27.7 255.255.255.0
ospf network-type p2p
#
[AR8]display current-configuration interface gigabitethernet0/0/2
#
interface GigabitEthernet0/0/2
ip address 100.1.27.8 255.255.255.0
ospf network-type p2p
#
当接口在OSPF协议视图中被设置为静默端口时,它将不能发送OSPF Hello报文,因此OSPF邻居关系无法形成
命令:display current-configuration configuration ospf
例如:通过命令查看接口正确启动OSPF并设置为非静默端口,下例中配置了静默端口
[r4]display current-configuration configuration ospf
#
ospf 1 router-id 10.1.4.4
silent-interface GigabitEthernet0/0/2
peer 10.1.145.1
area 0.0.0.0
authentication-mode md5 1 plain HuaWei
network 10.1.4.4 0.0.0.0
network 10.1.145.4 0.0.0.0
查看OSPF路由是否正确加入到全局路由表内,只有加入到全局路由表的路由才能指导数据包的转发。如果相同的路由信息同时也从其他路由协议学到,为了确保OSPF学习的路由能够最终加入全局路由表,需要确保其优先级为最优
命令:display ip routing-table x.x.x.x verbose
[r4]display ip routing-table 10.1.6.6 verbose
Route Flags: R - relay, D - download to fib
---------------------------------------------------------------------
Routing Table : Public
Summary Count : 2
Destination: 10.1.6.6/32
Protocol: O_ASE Process ID: 1
Preference: 150 Cost: 100
NextHop: 10.1.145.5 Neighbour: 0.0.0.0
State: Active Adv Age: 02h11m44s
Tag: 100 Priority: medium
Label: NULL QoSInfo: 0x0
IndirectID: 0x0
RelayNextHop: 0.0.0.0 Interface: Serial1/0/0
TunnelID: 0x0 Flags: D
Destination: 10.1.6.6/32
Protocol: Static Process ID: 0
Preference: 190 Cost: 0
NextHop: 10.1.145.1 Neighbour: 0.0.0.0
State: Inactive Adv Relied Age: 00h00m03s
Tag: 0 Priority: medium
Label: NULL QoSInfo: 0x0
IndirectID: 0x80000002
RelayNextHop: 0.0.0.0 Interface: Serial1/0/0
TunnelID: 0x0 Flags: R
若查看OSPF路由表未发现相应路由信息,请首先确认路由信息是否在OSPF中正确发布,对于未进行发布的路由请修改配置将路由正确发布
命令:display current-configuration configuration ospf
例如:查看10.1.145.4/24的路由信息是否在OSPF中发布
[r4]display current-configuration configuration ospf
#
ospf 1 router-id 10.1.4.4
peer 10.1.145.1
area 0.0.0.0
network 10.1.4.4 0.0.0.0
network 10.1.145.4 0.0.0.0
确认OSPF LSDB数据库中是否存在路由计算所需的正确LSA信息。
对于区域内的路由需要检查是否存在该路由始发者的Router LSA,DR的Network LSA(广播网络);
对于区域间的路由需要首先检查是否存在LS ID为该网段的Summary LSA,然后检查是否存在该Summary LSA所对应Adv Rtr的Router LSA;
如果外部路由是通过区域内学习到的,需要首先检查是否存在LS ID为该网段的ASE LSA,然后检查是否存在该ASE LSA中所对应Adv Rtr的Router LSA;
如果外部路由是通过区域间学到的那么首先检查对应的ASE LSA,然后检查是否存在该ASE LSA所对应Adv Rtr的Asbr Sumarry LSA,最后检查该Asbr Summary LSA所对应Adv Rtr的Router LSA。
命令:display ospf lsdb router
display ospf lsdb network
display ospf lsdb summary
display ospf lsdb asbr
display ospf lsdb ase
例如:通过命令查看外部路由9.9.9.9相关的LSA信息。
OSPF Process 1 with Router ID 10.1.4.4
Link State Database
Type : External
Ls id : 171.10.0.0
Adv rtr : 10.1.5.5
Ls age : 1145
Len : 36
Options : E
seq# : 80000005
chksum : 0xf24b
Net mask : 255.255.252.0
TOS 0 Metric: 100
E type : 2
Forwarding Address : 0.0.0.0
Tag : 100
Priority : Low
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Type : Sum-Asbr
Ls id : 10.1.5.5
Adv rtr : 10.1.1.1
Ls age : 1129
Len : 28
Options : E
seq# : 80000005
chksum : 0xe3ec
Tos 0 metric: 101
Type : Sum-Asbr
Ls id : 10.1.5.5
Adv rtr : 10.1.3.3
Ls age : 1132
Len : 28
Options : E
seq# : 80000005
chksum : 0xdd53
Tos 0 metric: 1
Area: 0.0.0.34
Link State Database
Area: 0.0.0.224
Link State Database
Type : Sum-Asbr
Ls id : 10.1.5.5
Adv rtr : 10.1.4.4
Ls age : 1196
Len : 28
Options : E
seq# : 80000006
chksum : 0xa658
Tos 0 metric: 48
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Type : Router
Ls id : 10.1.1.1
Adv rtr : 10.1.1.1
Ls age : 1155
Len : 72
Options : ASBR ABR E
seq# : 80000012
chksum : 0x7ddd
Link count: 4
* Link ID: 10.1.1.1
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID: 10.1.145.1
Data : 10.1.145.1
Link Type: TransNet
Metric : 48
* Link ID: 157.68.1.0
Data : 255.255.255.0
Link Type: StubNet
Metric : 48
Priority : Low
* Link ID: 10.1.5.5
Data : 10.1.135.1
Link Type: Virtual
Metric : 101
Area: 0.0.0.34
Link State Database
Area: 0.0.0.224
Link State Database
例如:通过命令查看区域内路由10.1.145.0/24相关的LSA信息
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Area: 0.0.0.34
Link State Database
Type : Sum-Net
Ls id : 10.1.145.0
Adv rtr : 10.1.4.4
Ls age : 674
Len : 28
Options : None
seq# : 80000006
chksum : 0xfa7f
Net mask : 255.255.255.0
Tos 0 metric: 48
Priority : Low
Area: 0.0.0.224
Link State Database
Type : Sum-Net
Ls id : 10.1.145.0
Adv rtr : 10.1.4.4
Ls age : 693
Len : 28
Options : E
seq# : 80000006
chksum : 0xdc9b
Net mask : 255.255.255.0
Tos 0 metric: 48
Priority : Low
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Type : Router
Ls id : 10.1.4.4
Adv rtr : 10.1.4.4
Ls age : 636
Len : 48
Options : ASBR ABR E
seq# : 8000000e
chksum : 0x4d3f
Link count: 2
* Link ID: 10.1.4.4
Data : 255.255.255.255
Link Type: StubNet
Metric : 0
Priority : Medium
* Link ID: 10.1.145.1
Data : 10.1.145.4
Link Type: TransNet
Metric : 48
例如:通过命令查看区域间路由10.1.35.0/24相关的LSA信息
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Type : Sum-Net
Ls id : 10.1.35.0
Adv rtr : 10.1.3.3
Ls age : 67
Len : 28
Options : E
seq# : 80000006
chksum : 0xd047
Net mask : 255.255.255.0
Tos 0 metric: 1
Priority : Low
OSPF Process 1 with Router ID 10.1.4.4
Area: 0.0.0.0
Link State Database
Type : Router
Ls id : 10.1.3.3
Adv rtr : 10.1.3.3
Ls age : 83
Len : 36
Options : ASBR ABR E
seq# : 80000006
chksum : 0xae32
Link count: 1
* Link ID: 10.1.5.5
Data : 10.1.35.3
Link Type: Virtual
Metric : 1
导致OSPF数据库中LSA异常或缺失的原因主要包括如下几种情况,需要从相关的配置或规划角度进行修正
1.骨干区域被分割,导致LSA缺失
2.虚连接配置错误,导致LSA缺失
3.RouterID冲突,导致LSA震荡
若外部路由携带FA地址确认FA路由为有效路由。OSPF必须能够通过区域内或区域间路由到达该FA地址,否则该外部路由不会加入OSPF路由表。
例如:外部路由172.1.40.0携带了FA地址为10.1.4.4,通过OSPF内部路由能够学习到10.1.4.4的路由,外部路由172.1.40.0正确加入路由表
OSPF Process 23 with Router ID 172.1.23.3
Link State Database
Type : External
Ls id : 172.1.40.0
Adv rtr : 172.1.23.3
Ls age : 718
Len : 36
Options : E DN
seq# : 80000001
chksum : 0xa2e5
Net mask : 255.255.255.0
TOS 0 Metric: 1
E type : 2
Forwarding Address : 1.1.4.4
Tag : 3489661273
Priority : Low
OSPF Process 1 with Router ID 10.1.3.3
Destination : 10.1.4.4/32
AdverRouter : 10.1.5.5 Area : 0.0.0.35
Cost : 49 Type : Stub
NextHop : 10.1.35.5 Interface : GigabitEthernet0/0/1
Priority : Medium Age : 00h13m22s
排查路由策略过滤路由的配置是否正确。
Route-policy : policy1
permit : 10 (matched counts: 0)
Match clauses :
if-match acl 2000
Apply clauses :
apply cost 100
apply tag 100
查看OSPF的路由优先级
Route Flags: R - relay, D - download to fib
---------------------------------------------------------------------
Routing Tables: Public
Destinations : 35 Routes : 35
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.1.1.1/32 OSPF 10 2 D 10.1.35.5 GigabitEthernet 0/0/1
10.1.2.2/32 O_ASE 150 1 D 10.1.35.5 GigabitEthernet0/0/1
10.1.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0
最后huaweicase吧#