【转ITAA上justdoit的一篇帖子】 验证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
察看R2的OSPF数据库
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网段,由于R2到ASBR R1的cost是64,到另一个ASBR R5的cost是128,所以选择R1是没有疑义的,现在我们将R2到R1的metric值改大,看看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 E1比O 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通告的外部路由,此时虽然到R5的cost小,但是没有考虑,
可见优先比较O E1和O E2是首要条件
最后总结一下:(说法不同于开始的规则,只是更简单)
(1)OSPF中外部路由类型不同,优先选择O E1路由
(2)OSPF中外部路由类型相同,看到ASBR的cost值,越小越优先
[注:实际实验效果是这样,也就是我们看拓扑图,可以这样分析;但是路由器实际处理过程还是本贴开始的那个规则更符合实际情况]
重要问题补充说明:
在案例一和案例二中,外部路由类型相同,此时路由器看到ASBR的cost值决定路径,实际上这是OSPF内部选路的问题,从哪 里到达ASBR;而在OSPF内部选路时,第一个原则就是“O路由”>“O IA路由”,而案例二的后半步,在更改了到同一区域ASBR的cost值以后,可以发现走了从O IA路由学习到的ASBR,可见在对ASBR的选路,访问外部路由时,这个原则无效.
【转ITAA上justdoit的一篇帖子】 验证OSPF中对外部路由路由的选择规则【留档】相关推荐
- php layui ajax多图上传,Laravel+Layer实现图片上传功能(整理篇)
♩ 背景 昨天在自己的 Laravel5.5 框架项目中,希望集成 Layer 的图片上传功能 但是在 ajax(POST) 提交请求时,一直显示 500 报错 ♪ 分析 ⒈ 问题所在 最后将核心代码 ...
- C#正在被人用来做什么?--在CSDN上引发小讨论的帖子
C#正在被人用来做什么?--在CSDN上引发小讨论的帖子 主 题: C#正在被人用来做什么? 作 者: manio (马牛) 等 级: 信 誉 值: 100 所属社区: .NET技 ...
- elementUI + vue 地址跳转:无法返回上一页 - 解决篇
elementUI + vue 项目:浏览器无法返回上一页 ?总是停留在当前页面? 代码块1: 不能正常返回上一页 // 成功之后执行跳转 this.$router.pushthis.$router. ...
- 天龙八部TLBB搭建(四)游戏端和补丁及上传CentOS修改篇
天龙八部TLBB搭建(四)游戏端和补丁及上传CentOS修改篇 首先我们要知道一个完整的游戏的端包括 服务器端和补丁文件 tlbb.tar.gz为服务器端文件,大小应该在50-60左右 补丁的话看版本 ...
- 使用Unity实现VR中在黑板上写字(升级篇)(一)-----解决画笔穿透画板的问题
一.概述: 在使用Unity实现VR中在黑板上写字(初级篇)中的最后留下了一些有待完善的地方,首先完善画笔穿透画板的问题: 在之前使用画笔会出现这种情况: 可以看到画笔是穿透了画板,这样在VR中会给用 ...
- Markdown 快速入门上(基础语法篇)
Markdown 快速入门上(基础语法篇) 1. 简介 Markdown 是一门轻量级的标记性语言,可以用来修饰纯文本使得文档具有一定的优美格式. 像Microsoft Word 文本编辑器, 你需要 ...
- 初二计算机听课笔记,初二物理上听课记录20篇
初中物理应讲究教与学.讲与练.主导与主体.学知识与学做人.学知识与提高能力.全面要求与因材施教等这都是在课堂教学中引出,在课堂教学中展开,又在课堂教学中运行,以何种形式来优化就可能带来不同的教学效果. ...
- 文件上传漏洞-原理篇
目录 第1章 文件上传漏洞基础 1.1 漏洞概述 1.2 漏洞成因 1.3 漏洞危害 1.4 漏洞利用姿势 第2章 文件上传漏洞检测与绕过 2.1 前端检测和绕过 2.2 服务器端检测和绕过 第3章 ...
- Koin--适用于Kotlin的超好用依赖注入框架,Dagger替代者,Koin史上最详细解说,一篇就够了,妈妈再也不用担心我不会依赖注入了
今年呆在家中实在无聊,外面太危险了,还是在家学习比较安全可持续. 过年期间,我又复习了几遍依赖注入框架Dagger. 诶,什么是依赖注入? 说白了就是降低跟类对象之间的耦合,当需要修改类对象的时候,能 ...
- 有了这篇文章, Python 中的编码不再是噩梦
有了这篇文章, Python 中的编码不再是噩梦 Python 中编码问题,一直是很多 Python 开发者的噩梦,尽管你是工作多年的 Python 开发者,也肯定会经常遇到令人神烦的编码问题,好不容 ...
最新文章
- suse linux查版本号,查看SUSE版本号
- 程序中 设置jvm 参数_高效应用程序的7个JVM参数
- 神盾局特工第四季/全集Agents Of SHIELD迅雷下载
- java成员内部类_Java中的内部类(二)成员内部类
- 华为笔记本会不会用鸿蒙,华为MateBook Pro笔记本为什么不用鸿蒙操作系统HarmonyO?...
- html 下拉列表返回值,jquery 根据后台返回值来选中下拉框 option 值
- JavaScript Math.random()随机数函数
- 微信公众号测试账号获取授权须关注
- 解决办法:为什么我的DLL中加载后找不到指定的函数
- redis源码阅读—hyperloglog(基数统计)
- 给定两个有序整数数组 nums1 和 nums2,将 nums2 合并到 nums1 中,使得 num1 有序
- 神经网络训练算法的调用,人工神经网络训练案例
- 模仿iOS版微信的滑动View
- 获取图片的EXIF信息如此困难?
- IAR打开软件,很多文件找不到
- 2016年8月25日 星期四 --出埃及记 Exodus 16:26
- 弘辽科技:四招教你快递提升店铺DSR。
- 苹果iPhone 14摄像头拆解分析
- php加速配置,php 提速工具eAccelerator 配置参数详解
- 达内CEO出席第三届软件服务外包年会