您的位置:首页 > 其它

Cisco OSPF 外部路由记录的路由选择

2011-08-28 20:57 302 查看
OSPF 外部路由记录有E1 E2 N1 N2 4种类型。 如果一台路由器同时收到了到达同一目的的这4种路由记录,那么哪条或者哪几条才会被加入路由表呢?

见下图:

OSPF router-id :

R1: 1.1.1.1

R2: 2.2.2.2

R7: 7.7.7.7

R8: 8.8.8.8

R9: 9.9.9.9



第一步:

在 R8 上,使用“redistribute connected” 把Loopback 0接口重发布进OSPF,并设置metric-type 1 (E1) .

在Area 6里面,有2个ABR:R2和 R9 。按规矩办事,7类LSA 转换为5类LSA 的工作由多台ABR中具有
最大router-id的路由器负责, R9 的 router-id比 R2的大,所以这个例子里,LSA 7-》 LSA 5转换以及对
Area 0宣告E1记录的工作 由 R9完成。

好了,现在所有路由器上的OSPF进程全部装载结束了。 R2 收到了2条通往 81.0.0.0这个网络的记录
(因为R2同时是ABR,自己可以学到一条到N1类型的81.0.0.0的记录,另一条到81.0.0.0 的记录是自R9
重发布后宣告的 E1类型LSA 记录)。 这2条路由记录具有相同的度量值,但在R2上show ip ro 却只能
看到一条E1的记录。

R2#sh ip ospf database external 81.0.0.0

OSPF Router with ID (2.2.2.2) (Process ID 10)

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 353

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 81.0.0.0 (External Network Number )

Advertising Router: 9.9.9.9

LS Seq Number: 80000001

Checksum: 0x51EC

Length: 36

Network Mask: /8

Metric Type: 1 (Comparable directly to link state metric)

TOS: 0

Metric: 20

Forward Address: 172.30.156.6

External Route Tag: 0

R2#sh ip ospf database nssa-external 81.0.0.0

OSPF Router with ID (2.2.2.2) (Process ID 10)

Type-7 AS External Link States (Area 6)

LS age: 1804

Options: (No TOS-capability, Type 7/5 translation, DC)

LS Type: AS External Link

Link State ID: 81.0.0.0 (External Network Number )

Advertising Router: 8.8.8.8

LS Seq Number: 80000001

Checksum: 0xDA5D

Length: 36

Network Mask: /8

Metric Type: 1 (Comparable directly to link state metric)

TOS: 0

Metric: 20

Forward Address: 172.30.156.6

External Route Tag: 0

O E1 81.0.0.0/8 [110/148] via 172.30.156.10, 00:05:39, Serial0/0.208

从这里可以看出,具有相同度量值的2条记录,N1 和 E1 ,
E1的优先级高于N1.

第二步:

在R7上配置loopback0接口到81.0.0.0子网并重发布进OSPF,激活R2和R7之间的链接(图中蓝色线段表示)。
把R7也丢到OSPF Area6里面.在R9上使用not-advertise命令拒绝掉Type 7 -> Type 5转换。
现在R2 上也学到2条通往81.0.0.0这个子网的路由,一条是R8发布的N1,另一条是R7发布的N1.

O N1 81.0.0.0/8 [110/148] via 172.30.156.14, 00:00:07, Serial0/0.207

[110/148] via 172.30.156.10, 00:00:07, Serial0/0.208


R2对这两条N1路由做了负载均衡~~

总结一下:

1) N1和 E1 要优先与N2和 E2 。 N1,E1 > N2,E2

2) 当N1 和 E1 都到达相同目的时 , 具有最小cost/metric的路由才会被加入路由表。

3) 如果N1和E1 都到达相同的目的,并且N1和 E1的开销一样,那么E1会比N1优先加入路由表。

4) 当2条路由都是N1时 , p-bit =1的 优先于 p-bit=0的。(无法验证,思科设备不能改P值***)

5) 当p-bit相同, 又到达相同目的地,则这些路由即负载均衡。

*** 当p-bit 为1的时候这条才是NSSA. 如果p-bit = 0 , 则这条就是E1了



原文:

Hi Guys,

To confirm all the points, i configured a lab with 5 routers R1,R2, R7, R8 and R9 as in the above topology.

Step 1:

On R8, i redstributed Loopback 0 interface in the OSPF by using "redstibute connected" command with metric-type 1. As, R2 and R9 both are acting as ABR for area 6, the type 7 to type 5 LSA translation will be performed by the router which has higher router
id. In this case router 9 has router-id 9.9.9.9 and R2 has 2.2.2.2. So, translation is done by R9 and will advertise the route as E1 in area 0. Now R2 which is acting as ABR has 2 routes for network 81.0.0.0, one as N1 route advertised by R8 and other as E1
route translated by R9. Both have same metric. When i checked routing table on R2, it gave preference to E1 over N1 and put E1 route in the routing table as below:

R2#sh ip ospf database external 81.0.0.0

OSPF Router with ID (2.2.2.2) (Process ID 10)

Type-5 AS External Link States

Routing Bit Set on this LSA

LS age: 353

Options: (No TOS-capability, DC)

LS Type: AS External Link

Link State ID: 81.0.0.0 (External Network Number )

Advertising Router: 9.9.9.9

LS Seq Number: 80000001

Checksum: 0x51EC

Length: 36

Network Mask: /8

Metric Type: 1 (Comparable directly to link state metric)

TOS: 0

Metric: 20

Forward Address: 172.30.156.6

External Route Tag: 0

R2#sh ip ospf database nssa-external 81.0.0.0

OSPF Router with ID (2.2.2.2) (Process ID 10)

Type-7 AS External Link States (Area 6)

LS age: 1804

Options: (No TOS-capability, Type 7/5 translation, DC)

LS Type: AS External Link

Link State ID: 81.0.0.0 (External Network Number )

Advertising Router: 8.8.8.8

LS Seq Number: 80000001

Checksum: 0xDA5D

Length: 36

Network Mask: /8

Metric Type: 1 (Comparable directly to link state metric)

TOS: 0

Metric: 20

Forward Address: 172.30.156.6

External Route Tag: 0

O E1 81.0.0.0/8 [110/148] via 172.30.156.10, 00:05:39, Serial0/0.208

We can see the metric and forwarding address is same for nssa-external and external and preference has been given to the E1 as expected.

Step 2:

Then I configured the same network 81.0.0.0 as loopback 0 on router 7 also and redstributed that in OSPF. Then i activated the link b/w R2 and R7 as shown in blue in the topology and put that also in area 6 and i stopped R9 from
doing translation from R7 to R5 by using not-advertise command. Now, R2 has 2 routes to network 81.0.0.0, both are N1, one advertised by R8 and other by R7 and got output as expected:

O N1 81.0.0.0/8 [110/148] via 172.30.156.14, 00:00:07, Serial0/0.207

[110/148] via 172.30.156.10, 00:00:07, Serial0/0.208


R2 load balanced the link and used both the routes.

So, what could i undersatnd from all this is:

Final Summary:

1) N1 and E1 will be prefered over N2 and E2

2) When N1 & E1 have the same route to the destination, The one that have lower cost / Metric will win and get into the route table

3) If both N1 & E1 have the same cost, E1 will be prefered over N1 whatever the value of P is?

4) If both routes are N1, the route with p=1 will be prefered over p=0

5) If value of P is also same , then routes will be load balanced and both will be used.

Point 4, i have marked in red because i could not confirm this and not sure about it. Whenever we redstribute a network in NSSA, value of P is set to 1 automatically. I tried but did not find any command to change the value to 0. Could you please tell me
the command to change value of P.
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: