OSPF路由选择排障案例 案例简介本案例中涉及OSPF在特定情况下的LSA选择问题,此问题关联了FA地址及NSSA的一些特性。通过对故障逐一分析,也汇总了相关知识。以下是一个真实案例, 为保护客户资料, 路由器输出信息已被修改。故障诊断步骤R1, R2 和 R3是NSSA区域,R1和R2是骨干区域。在R3上重分发网络10.10.119.0/27到NSSA中。客户发现R2正常从R3习得此NSSA路由,但是R1是从R2学来的E1路由。 1. 收集信息,确认问题,发现R1和R2都有TYPE 7和TYPE 5 路由,但R1选了TYPE5而R2选择了NSSA,这是为什么?[1]R1#show ospf database external 10.10.119.0 OSPF Router with ID (10.10.191.131) (Process ID 18181) Type-5 AS External Link States Routing Bit Set on this LSA LS age: 652 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 10.10.119.0 (External Network Number) Advertising Router: 10.10.191.132 LS Seq Number: 80000399 Checksum: 0x3768 Length: 36 Network Mask: /27 Metric Type: 1 (Comparable directly to link state metric) TOS: 0 Metric: 1 Forward Address: 10.10.72.89 External Route Tag: 1R1#sh ospf database nssa-external 10.10.119.0 OSPF Router with ID (10.10.191.131) (Process ID 18181) Type-7 AS External Link States (Area 7) LS age: 312 Options: (No TOS-capability, Type 7/5 translation, DC) LS Type: AS External Link Link State ID: 10.10.119.0 (External Network Number) Advertising Router: 10.10.72.89 LS Seq Number: 8000fe93 Checksum: 0x240 Length: 36 Network Mask: /27 Metric Type: 1 (Comparable directly to link state metric) TOS: 0 Metric: 1 Forward Address: 10.10.72.89 External Route Tag: 12. 根据数据库的信息,R1学来的E1路由应该是R2把TYPE7转为TYPE5后,发给R1的。仔细查看路由表,发现虽然R1从R2学来的路由,但下一跳仍然通过R3,这是为什么?[2]这些端口都在NSSA中,NSSA中会有5类路由么?[3]R2#show route 10.10.119.0 de Tag 1, type NSSA extern 1 10.10.183.142, from 10.10.72.89, via TenGigE0/0/0/0 10.10.183.98, from 10.10.72.89, via TenGigE0/1/2/0R1#show route10.10.119.0 de Tag 1, type extern 1 10.10.183.74, from 10.10.191.132, via TenGigE0/2/0/0 10.10.183.138, from 10.10.191.132, via TenGigE0/3/2/0R1#show ospf inter ten0/2/0/0 | i Area Internet Address 10.10.183.73/30, Area 7R1#R1#show ospf inter ten0/3/2/0 | i Area Internet Address 10.10.183.137/30, Area 73. 首先R1和R2是ABR,所以即使存在5类路由也是ok的,那么为什么从R2学来的路由,反而从R3走呢?[4]因为FA地址,对于FA地址简单回忆下:o 它是OSPF特有的,它的作用主要是在告诉域内路由器在特定场合下访问域外路由不要找ASBR,要找FA这个转发地址 o 只有满足特定条件,FA地址才不为"0.0.0.0",详细规则请看相关文档o 如果把FA地址过滤掉,那么这个外部路由不会加入路由表o 只有当FA地址为(intra-area)O或IA(inter-area)时,才可以把此E2路由放入路由表。小心重分发静态到OSPF,如果写的下一跳是地址,而且属于直连,他不会被加入路由表;相反写端口可以,因为不符合规则,FA全零o 在NSSA跟正常区域不同,根据"RFC 3101, specially section 2.3 Type-7 LSAs",转换时必须有FA地址,所以如果重分发静态时,下一跳写成端口,FA会成为全零,这样会有问题。 "6. Those Type-7 LSAs that are to be translated into Type-5 LSAs must have their forwarding address set."4. 根据上面的信息,已经很清楚的知道,虽然路由从R2学来,但转发仍然根据FA从跟R3直连的端口出去。5. 那么对于为什么R1会从R2学来E1,而不是R2从R1学E1,有什么规律么?[5]搭个环境测试下,发现很容易能重现问题,看来这是正常的,那么有文档么?[6]6. 查了下RFC,发现了下面的信息可以解释上面的疑问:o 对于为什么R1从R2学来E1路由,根据RFC 2328的信息: "If two routers, both reachable from one another, originate functionally equivalent AS-external-LSAs (i.e., same destination, cost and non-zero forwarding address), then the LSA originated by the router having the highest OSPF Router ID is used."因为R2(132) 优于R1(131),所以R2转换并发给R1。o 对于为什么R1选择了E1而不是NSSA,根据RFC 1587: "When a type-5 LSA and a type-7 LSA are found to have the same type and an equal distance, the following priorities apply (listed from highest to lowest) for breaking the tie. a. Any type 5 LSA.b. A type-7 LSA with the P-bit set and the forwarding address non-zero.c. Any other type-7 LSA."解答总结[1] 根据RFC1587,当type-5 和type-7有同样类型和同样距离时,type-5 > type-7(P-bit+FA) > type-7[2] 当LSA有FA地址时,需要向FA地址转发,而不是向ASBR转发。[3] 如果一个路由器属于NSSA,他不会存在type-5 LSA,但如果此路由器是ABR,那么是有可能的。[4] FA地址。[5] 根据RFC 2328,如果两个路由器彼此可达,当两台设备产生等价LSA时,将使用拥有高Router ID的LSA。[6] RFC 2328,RFC1587相关命令show ospf database external x.x.x.xshow ospf database nssa x.x.x.xshow route x.x.x.x detailshow ospf inter xxx | i xxx