打印

OSPF-2:Forwarding Address对LSA5的路径选择影响.

OSPF-2:Forwarding Address对LSA5的路径选择影响.

介绍:
本试验测试OSPF路由器收到某个外部网络的LSA 5通告时,如果转发地址不为0.0.0.0,对路径选择的影响。


转发地址如何影响LSA5选路:


以下拓扑,除了R8,均在Area 0;R3\R4重发布进OSPF的静态路由的下一跳地址为172.16.3.x。


注意:R3/R4不将172.16.3.x/24接口运行OSPF

Router 3
interface Ethernet0 ip address 172.16.3.3 255.255.255.0 ip ospf cost 15!interface Serial0 ip address 172.16.2.3 255.255.255.0!router ospf 7 redistribute static subnets network 172.16.2.0 0.0.0.255 area 0!ip route 200.200.200.0 255.255.255.0 172.16.3.8

Router 4
interface Ethernet0 ip address 172.16.3.4 255.255.255.0!interface Serial0 ip address 172.16.7.4 255.255.255.0!router ospf 7 redistribute static subnets network 172.16.7.0 0.0.0.255 area 0!ip route 200.200.200.0 255.255.255.0 172.16.3.8

因为R3/R4对应静态路由的下一跳接口不运行OSPF,因此产生的LSA 5均将Forwarding Address表示为0.0.0.0

Router 5
router-5# show ip ospf database external OSPF Router with ID (172.16.6.5) (Process ID 7) Type-5 AS External Link States Routing Bit Set on this LSA LS age: 1514 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 200.200.200.0 (External Network Number ) Advertising Router: 172.16.3.3 LS Seq Number: 80000030 Checksum: 0x93C0 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 0 Routing Bit Set on this LSA LS age: 1922 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 200.200.200.0 (External Network Number ) Advertising Router: 172.16.7.4 LS Seq Number: 80000027 Checksum: 0x83D4 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 0

R5选择到达外部路由,根据到最近ASBR原则,会选择从R3访问外部路由:

Router 5
router-5# show ip ospf border-routersOSPF Process 7 internal Routing TableCodes: i - Intra-area route, I - Inter-area routei 172.16.7.4 [74] via 172.16.6.6, Ethernet0, ASBR, Area 0, SPF 15i 172.16.3.3 [64] via 172.16.2.3, Serial0, ASBR, Area 0, SPF 15router-5#

Router 5
router-5# show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static routeGateway of last resort is not setO E2 200.200.200.0/24 [110/20] via 172.16.2.3, 19:59:25, Serial0 172.16.0.0/24 is subnetted, 3 subnetsC 172.16.6.0 is directly connected, Ethernet0O 172.16.7.0 [110/74] via 172.16.6.6, 19:59:25, Ethernet0C 172.16.2.0 is directly connected, Serial0router-5#







到这一步,看不出有任何异常。

接下来,将R3的E0口运行OSPF,会导致R3发布出来的LSA 5携带不为0.0.0.0的转发地址。

Router 3
interface Ethernet0 ip address 172.16.3.3 255.255.255.0 ip ospf cost 15!router ospf 7 network 172.16.3.0 0.0.0.255 area 0!增加以上粗体部分命令1条

在R5查看收到的LSA 5,较之前发生一些变化:

Router 5
router-5# show ip ospf database external OSPF Router with ID (172.16.6.5) (Process ID 7) Type-5 AS External Link States Routing Bit Set on this LSA LS age: 270 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 200.200.200.0 (External Network Number ) Advertising Router: 172.16.3.3 LS Seq Number: 80000033 Checksum: 0x5138 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 172.16.3.8 External Route Tag: 0 Routing Bit Set on this LSA LS age: 258 Options: (No TOS-capability, DC) LS Type: AS External Link Link State ID: 200.200.200.0 (External Network Number ) Advertising Router: 172.16.7.4 LS Seq Number: 80000029 Checksum: 0x7FD6 Length: 36 Network Mask: /24 Metric Type: 2 (Larger than any link state path) TOS: 0 Metric: 20 Forward Address: 0.0.0.0 External Route Tag: 0router-5#

发生变化的根本原因是,重发布的静态路由的下一跳地址172.16.3.8所在网段172.16.3.x/24,R3已经将该网段接口运行了OSPF。

现在查看到ASBR的开销,和之前一致,到R4的开销较大,为74

Router 5
router-5# show ip ospf border-routersOSPF Process 7 internal Routing TableCodes: i - Intra-area route, I - Inter-area routei 172.16.7.4 [74] via 172.16.6.6, Ethernet0, ASBR, Area 0, SPF 15i 172.16.3.3 [64] via 172.16.2.3, Serial0, ASBR, Area 0, SPF 15router-5#


但如果再进一步查看路由表,则会发现路由器选择到“开销较大"的ASBR

Router 5
router-5# show ip routeCodes: C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static routeGateway of last resort is not setO E2 200.200.200.0/24 [110/20] via 172.16.6.6, 00:35:14, Ethernet0 172.16.0.0/24 is subnetted, 4 subnetsC 172.16.6.0 is directly connected, Ethernet0O 172.16.7.0 [110/74] via 172.16.6.6, 00:35:14, Ethernet0C 172.16.2.0 is directly connected, Serial0O 172.16.3.0 [110/79] via 172.16.2.3, 00:35:14, Serial0

出现这种情况的根本原因,在于开销一致的情况下(均为OE2,开销=20),OSPF先对比到LSA 5转发地址的开销,而到R3发布的LSA转发地址开销为79:

Router 5
router-5# show ip route 172.16.3.8Routing entry for 172.16.3.0/24 Known via "ospf 7", distance 110, metric 79, type intra area Last update from 172.16.2.3 on Serial0, 00:30:49 ago Routing Descriptor Blocks: * 172.16.2.3, from 172.16.3.3, 00:30:49 ago, via Serial0 Route metric is 79, traffic share count is 1

因此到R4的转发地址0.0.0.0的开销74反而显小了。

至于0.0.0.0代表什么地址呢?这个地址表示路由器本身,取到这个路由器最近的开销,show ip ospf border-routers,正是查看到这个路由本身最近的开销。而OSPF在进行选路计算时,如果有更详细的信息,转发地址,则直接针对这部分信息计算。


yangrubing_ITAA QQ:383506128

TOP

OSPF-3:OSPF对外部路由的选路规则完全验证版

[实验目的]
验证OSPF中对外部路由路由的选择规则





OSPF在选择外部路由的时候,遵循的原则是:

[1]O E1
优于O E2


[2]
在同样的情况下,Cost越小越优先


[3]
cost相同的情况下,选择到达ASBR最优的路径



下面来通过实验来验证该规则:
[案例1]当外部路由都是O E1的情况

基本配置:(注意ASBR的配置)
R1:
interface Loopback0

ip address 1.1.1.1 255.255.255.0


ip ospf network point-to-point

!
interface Serial1/0

ip address 12.1.1.1 255.255.255.0

!
interface Serial2/0

ip address 13.1.1.1 255.255.255.0

!
router ospf 1
redistribute rip subnets metric-type 1

network 12.1.1.0 0.0.0.255 area 0

!
router rip

version 2


network 13.0.0.0


distance 109(因为RIP的AD大于OSPF,所以重发布到OSPF中,会发生路由抖动,故将其改小,详解看等级三实验手册1.3)


no auto-summary

!
R2:
interface Loopback0

ip address 2.2.2.2 255.255.255.0


ip ospf network point-to-point

!
interface Serial1/0

ip address 24.1.1.2 255.255.255.0

!
interface Serial2/0

ip address 12.1.1.2 255.255.255.0

!
router ospf 1
network 12.1.1.0 0.0.0.255 area 0

network 24.1.1.0 0.0.0.255 area 0

!


R3:
interface Loopback0

ip address 3.3.3.3 255.255.255.0


ip ospf network point-to-point

!
interface Serial1/0

ip address 13.1.1.3 255.255.255.0

!
interface Serial2/0

ip address 35.1.1.3 255.255.255.0

!
router rip

version 2


network 3.0.0.0


network 13.0.0.0


network 35.0.0.0


no auto-summary

!

R4:
interface Loopback0

ip address 4.4.4.4 255.255.255.0


ip ospf network point-to-point

!
interface Serial1/0

ip address 45.1.1.4 255.255.255.0

!
interface Serial2/0

ip address 24.1.1.4 255.255.255.0

!
router ospf 1
network 24.1.1.0 0.0.0.255 area 0

network 45.1.1.0 0.0.0.255 area 1

!


R5:
interface Loopback0

ip address 5.5.5.5 255.255.255.0


ip ospf network point-to-point

!
interface Serial1/0

ip address 35.1.1.5 255.255.255.0

!
interface Serial2/0

ip address 45.1.1.5 255.255.255.0

!
router ospf 1
redistribute rip subnets metric-type 1

network 45.1.1.0 0.0.0.255 area 1

!

router rip

version 2


network 35.0.0.0


distance 109


no auto-summary

!
监视和测试配置:


查看R2的路由表:
R2#sh ip rou

35.0.0.0/24 is subnetted, 1 subnets

O E1
35.1.1.0 [110/84] via 12.1.1.1, 00:00:25, Serial2/0


2.0.0.0/24 is subnetted, 1 subnets

C
2.2.2.0 is directly connected, Loopback0


3.0.0.0/24 is subnetted, 1 subnets

O E2
3.3.3.0 [110/84] via 12.1.1.1, 00:00:25, Serial2/0


24.0.0.0/24 is subnetted, 1 subnets

C
24.1.1.0 is directly connected, Serial1/0


12.0.0.0/24 is subnetted, 1 subnets

C
12.1.1.0 is directly connected, Serial2/0


13.0.0.0/24 is subnetted, 1 subnets

O E2
13.1.1.0 [110/84] via 12.1.1.1, 00:00:25, Serial2/0


45.0.0.0/24 is subnetted, 1 subnets

O IA
45.1.1.0 [110/128] via 24.1.1.4, 00:00:26, Serial1/0

查看R2的ospf数据库

R1#sh ip os da
Type-5 AS External Link States
Link ID ADV Router Age Seq# Checksum Tag
3.3.3.0 1.1.1.1 237 0x80000001 0x00D93A 0
3.3.3.0 5.5.5.5 239 0x80000001 0x0061A2 0
13.1.1.0 1.1.1.1 509 0x80000001 0x008588 0
13.1.1.0 5.5.5.5 239 0x80000001 0x000DF0 0
35.1.1.0 1.1.1.1 238 0x80000001 0x006691 0
35.1.1.0 5.5.5.5 381 0x80000001 0x00EDF9 0

可以看到R2从两个ASBR都收到了LSA 5的通告,但是R2选择了从R1走。ASBR通告外部路由默认都是以metric值20通告出去的,但是内部接受的路由器看到是 O E1的外部路由,会加上自己到ASBR的cost值来算出新的metric值,这样实际上在我们来看只要选择到ASBR cost值小的路由器就可以了。

[案例2]当外部路由都是O E2的情况
在ASBR R1和R5上更改重发布命令
R1(config)#router ospf 1
R1(config-router)#redistribute rip metric-type 2 subnets

R5(config)#router ospf 1
R5(config-router)# redistribute rip metric-type 2 subnets

(注意这里直接改为 redistribute rip subnets是没有效果的,因为前面已经将类型改为E1,这里没有指明类型,是不会改为O E2的;这样写只有原来没有作过重发布,类型默认才会为O E2)


监视和测试配置


R2#sh ip rou

35.0.0.0/24 is subnetted, 1 subnets

O E2
35.1.1.0 [110/20] via 12.1.1.1, 00:00:25, Serial2/0


2.0.0.0/24 is subnetted, 1 subnets

C
2.2.2.0 is directly connected, Loopback0


3.0.0.0/24 is subnetted, 1 subnets

O E2
3.3.3.0 [110/20] via 12.1.1.1, 00:00:25, Serial2/0


24.0.0.0/24 is subnetted, 1 subnets

C
24.1.1.0 is directly connected, Serial1/0


12.0.0.0/24 is subnetted, 1 subnets

C
12.1.1.0 is directly connected, Serial2/0


13.0.0.0/24 is subnetted, 1 subnets

O E2
13.1.1.0 [110/20] via 12.1.1.1, 00:00:25, Serial2/0


45.0.0.0/24 is subnetted, 1 subnets

O IA
45.1.1.0 [110/128] via 24.1.1.4, 00:00:26, Serial1/0


察看R2OSPF数据库
R2#sh ip os da

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



Type-5 AS External Link States


Link ID
ADV Router
Age
Seq#
Checksum Tag

3.3.3.0
1.1.1.1
1540
0x80000001 0x005D36 0

3.3.3.0
5.5.5.5
1551
0x80000001 0x00E49E 0

13.1.1.0
1.1.1.1

1540
0x80000001 0x000984 0

13.1.1.0
5.5.5.5
1551
0x80000001 0x0090EC 0

35.1.1.0
1.1.1.1
1540
0x80000001 0x00E98D 0

35.1.1.0
5.5.5.5
1551
0x80000001 0x0071F5 0

可以看到R2对于每一个外部条目都从两个边界路由器分别学到了,让我们看一下它通过两个ASBR学到3.3.3.0这个路由条目的metric值是多少
R2#sh ip os da ex 3.3.3.0

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



Type-5 AS External Link States



Routing Bit Set on this LSA


LS age: 1595


Options: (No TOS-capability, DC)


LS Type: AS External Link


Link State ID: 3.3.3.0 (External Network Number )


Advertising Router: 1.1.1.1


LS Seq Number: 80000001


Checksum: 0x5D36


Length: 36


Network Mask: /24


Metric Type: 2 (Larger than any link state path)


TOS: 0


Metric: 20


Forward Address: 0.0.0.0


External Route Tag: 0



LS age: 1606


Options: (No TOS-capability, DC)


LS Type: AS External Link


Link State ID: 3.3.3.0 (External Network Number )


Advertising Router: 5.5.5.5


LS Seq Number: 80000001


Checksum: 0xE49E


Length: 36


Network Mask: /24


Metric Type: 2 (Larger than any link state path)


TOS: 0


Metric: 20


Forward Address: 0.0.0.0


External Route Tag: 0

可以看到都是20,度量值一样,但是R2并没有作负载均衡,而是选择了从R1到达3.3.3.0网段,由于R2ASBR R1cost64,到另一个ASBR R5cost128,所以选择R1是没有疑义的,现在我们将R2R1metric值改大,看看R2是否还选择R1
R2(config)#int s2/0
R2(config-if)#ip ospf cost 200
R2(config-if)#end
重启OSPF进程看结果
R2#clear ip os pro
Reset ALL OSPF processes? [no]: y


R2#sh ip rou
Gateway of last resort is not set


35.0.0.0/24 is subnetted, 1 subnets

O E2
35.1.1.0 [110/20] via 24.1.1.4, 00:00:20, Serial1/0


2.0.0.0/24 is subnetted, 1 subnets

C
2.2.2.0 is directly connected, Loopback0


3.0.0.0/24 is subnetted, 1 subnets

O E2
3.3.3.0 [110/20] via 24.1.1.4, 00:00:20, Serial1/0


24.0.0.0/24 is subnetted, 1 subnets

C
24.1.1.0 is directly connected, Serial1/0


12.0.0.0/24 is subnetted, 1 subnets

C
12.1.1.0 is directly connected, Serial2/0


13.0.0.0/24 is subnetted, 1 subnets

O E2
13.1.1.0 [110/20] via 24.1.1.4, 00:00:20, Serial1/0


45.0.0.0/24 is subnetted, 1 subnets

O IA
45.1.1.0 [110/128] via 24.1.1.4, 00:00:20, Serial1/0

可以看到R2此时选择了R4作为下一条,也就是接收了R5通告的外部路由条目
[案例3]E1和E2路由共存的情况
下面我们将R1通告的外部路由类型改为 O E1,来验证O E1O E2优先
R1(config-router)#redistribute rip subnets metric-type 1
R2上重启OSPF进程看结果
R2#clear ip os pro
Reset ALL OSPF processes? [no]: y


R2#sh ip rou
Gateway of last resort is not set

R2#sh ip rou
Gateway of last resort is not set


35.0.0.0/24 is subnetted, 1 subnets

O E1
35.1.1.0 [110/220] via 12.1.1.1, 00:00:01, Serial2/0


2.0.0.0/24 is subnetted, 1 subnets

C
2.2.2.0 is directly connected, Loopback0


3.0.0.0/24 is subnetted, 1 subnets

O E1
3.3.3.0 [110/220] via 12.1.1.1, 00:00:01, Serial2/0


24.0.0.0/24 is subnetted, 1 subnets

C
24.1.1.0 is directly connected, Serial1/0


12.0.0.0/24 is subnetted, 1 subnets

C
12.1.1.0 is directly connected, Serial2/0


13.0.0.0/24 is subnetted, 1 subnets

O E1
13.1.1.0 [110/220] via 12.1.1.1, 00:00:01, Serial2/0


45.0.0.0/24 is subnetted, 1 subnets

O IA
45.1.1.0 [110/128] via 24.1.1.4, 00:00:02, Serial1/0

可以看到R2又一次选择了R1通告的外部路由,此时虽然到R5cost小,但是没有考虑,
可见优先比较O E1O E2是首要条件
最后总结一下:(说法不同于开始的规则,只是更简单)
(1)OSPF中外部路由类型不同,优先选择O E1路由
(2)OSPF中外部路由类型相同,看到ASBR的cost值,越小越优先
[注:实际实验效果是这样,也就是我们看拓扑图,可以这样分析;但是路由器实际处理过程还是本贴开始的那个规则更符合实际情况]

重要问题补充说明:
在案例一和案例二中,外部路由类型相同,此时路由器看到ASBR的cost值决定路径,实际上这是OSPF内部选路的问题,从哪 里到达ASBR;而在OSPF内部选路时,第一个原则就是“O路由”>“O IA路由”,而案例二的后半步,在更改了到同一区域ASBR的cost值以后,可以发现走了从O IA路由学习到的ASBR,可见在对ASBR的选路,访问外部路由时,这个原则无效.

TOP

本功能由奇虎搜索实现

相关主题

标题 作者 最后发表
[站外] 电脑术语大全   [转帖] 洛浩 2008-11-19
[站外] 电脑术语大全   [转帖] 洛浩 2008-11-19
[站外] LVS+Heartbeat+Ldirectord在Red Hat9.0下的实现   [转帖] linux 2008-11-11
点击阅读更多关于的相关帖子  更多相关主题