OSPF在企业网上的应用

简介:

OSPF在企业网上的应用

OSPF简介:

OSPF是Open Shortest Path First(开放最短路由优先协议)的缩写。他是IETF组织开发的一个基于链路状态的自治系统内部路由协议。

实验环境:cisco

一、

为什么要使用OSPF来作为企业网中的动态路由协议?

企业网内的动态路由,常用的就三种:rip,ospf和eigrp,前两种是公开协议,每个厂家的路由器都支持,最后一种是cisco的私有协议,只有思科路由器可以使用该协议。

rip只适合用于规模较小的网络,因为其原理,决定了网络越大,使用rip消耗的网络带宽、处理器、内存资源就越多。ospf和eigrp都考虑到了大型网络的需要,适合较大型的企业网,但eigrp是思科私有的,有些用户对其不太感冒,希望用开放的协议。

所以最后就只剩下ospf可以选了。 

OSPF有什么样的特点?

1、路由更新:触发更新,只有当网络结构发生变化时才进行路由更新;

2、网络规模:ospf最多可支持500台以上路由器工作;

3、具有认证机制,保证安全;

4、收敛的速度快;

5、负载均衡;

6、属于无环路径,不会形成路由环路。

7、支持vlsm子网和子网不连续

8、拥有区域划分功能,将故障屏蔽在单个区域;

9、丰富的策略,控制路由和报文

10、路由更新以组播的方式进行传递。

OSPF路由表形成的过程?

        wps_clip_image-14197

首先A向B发送hello包,当B接收到hello包后,将A添加到邻居表格。

然后B再向A发送hello包,当A接收到hello包后,将B添加到邻居表格,这时候A和B将达到two-way状态(双向状态)。

然后,比较路由器的优先级,选取出DR和BDR。若B为DR,所以A只能与B互换LSDB(链路状态数据库),在进行互换之前,A与B首先比较RouteID,可以发现B的RouteID大于A的,所以,B会先将自己的DBD(大纲)发送给A。A再将自己的DBD发送给B。两者都受到对方的DBD后,都会返回一个LSack(链路状态应答)。

当B获得A的DBD后,如果有陌生的条目,会再向A请求LSR(链路状态信息),然后,A会向B回复相应的信息LSU(链路状态更新)。直到A与B的LSDB达到一致后,两者处于full状态。

当A与B达到full状态后,每台路由器会通过SPF算法来计算最优的路由表格。

多区域OSPF有什么优点?

1、减少路由器的路由条目,从而减少资源的占用;

2、减少LSA的泛洪;减少由于网络不稳定而造成的,所有路由器泛洪LSA形成网络拥塞堵塞;

3、提高路由的效率:缩减部分路由器的OSPF路由条目,降低路由收敛的复杂度,对某些特定的lsa,可以在区域边界上,实现汇总/过滤/控制,而实现全网互通

二、

案例1:多区域OSPF和路由再发布

 

拓扑图:(地址方案)

        拓扑图

 

配置:(详细步骤和详细说明)

配置路由器R1:

en

conf t

line console 0

##配置日志同步

logging sy

##取消连接超时

no exec-t

exit

##为fa0/0配置地址

int fa 0/0

ip add 192.168.1.1 255.255.255.0

no shut

exit

##为serial2/0配置地址和时钟

int s 2/0

clock rate 64000

ip add 192.168.2.1 255.255.255.0

no shut

exit

##开启ospf并划分相应的区域

route ospf 100

network 192.168.1.0 0.0.0.255 area 1

network 192.168.2.0 0.0.0.255 area 1

exit

##查看路由表信息

Router#show ip route

Codes: 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 route

Gateway of last resort is not set

C    192.168.1.0/24 is directly connected, FastEthernet0/0

C    192.168.2.0/24 is directly connected, Serial2/0

O IA 192.168.3.0/24 [110/1562] via 192.168.2.2, 00:10:26, Serial2/0

O IA 192.168.4.0/24 [110/2343] via 192.168.2.2, 00:07:29, Serial2/0

O IA 192.168.5.0/24 [110/2344] via 192.168.2.2, 00:06:43, Serial2/0

O E2 192.168.6.0/24 [110/20] via 192.168.2.2, 00:05:00, Serial2/0

O E2 192.168.7.0/24 [110/20] via 192.168.2.2, 00:04:48, Serial2/0

Router#

Router#

配置路由器R2:

en

conf t

line console 0

##配置日志同步

logging sy

##取消连接超时

no exec-t

exit

##为serial3/0配置地址

int s 3/0

ip add 192.168.2.2 255.255.255.0

no shut

exit

##为serial2/0配置地址和时钟

int s 2/0

clock r

clock rate 64000

ip add 192.168.3.1 255.255.255.0

no shut

exit

##为fa0/0配置地址

int fa 0/0

ip add 192.168.6.1 255.255.255.0

no shut

exit

##开启ospf并划分相应的区域

route ospf 100

network 192.168.2.0 0.0.0.255 area 1

network 192.168.3.0 0.0.0.255 area 0

exit

##开启rip并配置路由转发的链路

route rip

network 192.168.6.0

exit

##配置从rip区域到ospf区域的重分发

route ospf 100

redistribute connected

redistribute rip

exit

##配置从ospf区域到rip区域的重分发

route rip

redistribute connected

redistribute ospf 100 metric 2

exit

%SYS-5-CONFIG_I: Configured from console by console

##查看路由表信息

Router#show ip rout

Codes: 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 route

Gateway of last resort is not set

O    192.168.1.0/24 [110/782] via 192.168.2.1, 00:10:55, Serial3/0

C    192.168.2.0/24 is directly connected, Serial3/0

C    192.168.3.0/24 is directly connected, Serial2/0

O IA 192.168.4.0/24 [110/1562] via 192.168.3.2, 00:08:02, Serial2/0

O IA 192.168.5.0/24 [110/1563] via 192.168.3.2, 00:07:17, Serial2/0

C    192.168.6.0/24 is directly connected, FastEthernet0/0

R    192.168.7.0/24 [120/1] via 192.168.6.2, 00:00:13, FastEthernet0/0

Router#

配置路由器R3:

en

conf t

line console 0

##配置日志同步

logging sy

##取消连接超时

no exec-t

exit

##为serial3/0配置地址

int s 3/0

ip add 192.168.3.2 255.255.255.0

no shut

exit

##为serial2/0配置地址和时钟

int s 2/0

clock ra

clock rate 64000

ip add 192.168.4.1 255.255.255.0

no shut

exit

##开启ospf并划分相应的区域

route ospf 100

network 192.168.3.0 0.0.0.255 area 0

network 192.168.4.0 0.0.0.255 area 2

exit

##查看路由表信息

Router#show ip rout

Codes: 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 route

Gateway of last resort is not set

O IA 192.168.1.0/24 [110/1563] via 192.168.3.1, 00:08:49, Serial3/0

O IA 192.168.2.0/24 [110/1562] via 192.168.3.1, 00:08:49, Serial3/0

C    192.168.3.0/24 is directly connected, Serial3/0

C    192.168.4.0/24 is directly connected, Serial2/0

O    192.168.5.0/24 [110/782] via 192.168.4.2, 00:07:41, Serial2/0

O E2 192.168.6.0/24 [110/20] via 192.168.3.1, 00:05:48, Serial3/0

O E2 192.168.7.0/24 [110/20] via 192.168.3.1, 00:05:36, Serial3/0

Router#

配置路由器R4:

en

conf t

line console 0

##配置日志同步

logging sy

##取消连接超时

no exec-t

exit

##为serial3/0配置地址

int s 3/0

ip add 192.168.4.2 255.255.255.0

no shut

exit

##为fa0/0配置地址

int fa 0/0

ip add 192.168.5.1 255.255.255.0

no shut

exit

##开启ospf并划分相应的区域

route ospf 100

network 192.168.4.0 0.0.0.255 area 2

network 192.168.5.0 0.0.0.255 area 2

exit

##查看路由表信息

Router#show ip rout

Codes: 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 route

Gateway of last resort is not set

O IA 192.168.1.0/24 [110/2344] via 192.168.4.1, 00:08:06, Serial3/0

O IA 192.168.2.0/24 [110/2343] via 192.168.4.1, 00:08:06, Serial3/0

O IA 192.168.3.0/24 [110/1562] via 192.168.4.1, 00:08:06, Serial3/0

C    192.168.4.0/24 is directly connected, Serial3/0

C    192.168.5.0/24 is directly connected, FastEthernet0/0

Router#

配置路由器R5:

en

conf t

line console 0

##配置日志同步

logging sy

##取消连接超时

no exec-t

exit

##为fa1/0配置地址

int fa 1/0

ip add 192.168.6.2 255.255.255.0

no shut

exit

##为fa0/0配置地址

int fa 0/0

ip add 192.168.7.1 255.255.255.0

no shut

exit

##开启rip并配置路由转发的链路

route rip

network 192.168.6.0

network 192.168.7.0

exit

##查看路由表信息

Router#show ip rout

Codes: 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 route

Gateway of last resort is not set

R    192.168.1.0/24 [120/2] via 192.168.6.1, 00:00:13, FastEthernet1/0

R    192.168.2.0/24 [120/1] via 192.168.6.1, 00:00:28, FastEthernet1/0

R    192.168.3.0/24 [120/1] via 192.168.6.1, 00:00:28, FastEthernet1/0

R    192.168.4.0/24 [120/2] via 192.168.6.1, 00:00:13, FastEthernet1/0

R    192.168.5.0/24 [120/2] via 192.168.6.1, 00:00:13, FastEthernet1/0

C    192.168.6.0/24 is directly connected, FastEthernet1/0

C    192.168.7.0/24 is directly connected, FastEthernet0/0

Router#

三、

小结:作为一种链路状态的路由协议,OSPF具备许多优点:快速收敛,支持变长网络屏蔽码,支持CIDR以及地址summary,具有层次化的网络结构,支持路由信息验证等。所有这些特点保证了OSPF路由协议能够被应用到大型的、复杂的网络环境中。



本文转自 cexpert 51CTO博客,原文链接:

http://blog.51cto.com/cexpert/950190
相关文章
|
SQL BI 数据库
达梦(DM) SQL日期操作及分析函数
讲述DM 数据库中如何实现各种日期相关的运算以及如何利用分析函数 lead() over() 进行范围问题的处理
|
搜索推荐 前端开发 数据安全/隐私保护
改善用户体验方法
【10月更文挑战第9天】改善用户体验方法
1260 3
|
9月前
|
安全 Linux API
Burp Suite Professional 2025.4 发布 - Web 应用安全、测试和扫描
Burp Suite Professional 2025.4 (macOS, Linux, Windows) - Web 应用安全、测试和扫描
439 6
Burp Suite Professional 2025.4 发布 - Web 应用安全、测试和扫描
|
机器学习/深度学习 计算机视觉
Make U-Nets Great Again!北大&华为提出扩散架构U-DiT,六分之一算力即可超越DiT
北京大学和华为研究人员提出U-shaped Diffusion Transformers(U-DiTs),重新审视U-Net架构在扩散模型中的潜力。通过引入Token Downsampling方法,U-DiTs在ImageNet 256x256和512x512生成任务中显著提升性能并降低计算成本。实验表明,U-DiT模型不仅超越了DiT模型的性能,在计算效率上也更具优势。论文地址:https://arxiv.org/pdf/2405.02730
310 43
|
域名解析 网络协议 Ubuntu
【域名解析DNS专栏】搭建私有DNS服务器:从BIND到CoreDNS的选择
【5月更文挑战第26天】本文对比了两种流行的DNS服务器软件BIND和CoreDNS。BIND以其稳定性及丰富功能著称,广泛兼容各类平台,适合复杂环境;CoreDNS则以其高性能、模块化设计和易用性脱颖而出。根据需求、资源和技术水平,用户可选择适合自己的DNS服务器。安装示例包括BIND在Ubuntu上的apt安装及基本配置,以及CoreDNS的snap安装和YAML配置。
1708 0
|
网络协议 定位技术 Windows
Windows Server 2019 DNS服务器搭建
Windows Server 2019 DNS服务器搭建
631 1
|
机器学习/深度学习 数据采集 数据可视化
【优秀python系统毕设】基于Python flask的气象数据可视化系统设计与实现,有LSTM算法预测气温
本文介绍了一个基于Python Flask框架开发的气象数据可视化系统,该系统集成了数据获取、处理、存储、LSTM算法气温预测以及多种数据可视化功能,旨在提高气象数据的利用价值并推动气象领域的发展。
1449 1
|
机器学习/深度学习 人工智能 异构计算
【Docker 专栏】Docker 与 GPU 加速应用的结合
【5月更文挑战第9天】GPU加速技术在处理大规模数据和复杂计算时展现强大性能,尤其在AI和深度学习领域。Docker作为轻量级容器化工具,提供隔离、可移植和高效的环境。结合GPU加速,关键在于容器访问GPU设备和安装相应驱动。NVIDIA提供了支持工具,允许Docker利用GPU。应用场景包括人工智能、科学计算和视频处理。优势包括资源利用率提升和部署灵活性,但面临驱动兼容性、资源管理和监控调试的挑战。未来,随着技术发展,Docker与GPU加速在边缘计算中的应用将有广阔前景。
761 1
【Docker 专栏】Docker 与 GPU 加速应用的结合
|
监控
揭秘:为何多年经验的网工还对光模块的光衰正常范围一知半解?这个秘密可能彻底改变你的网络优化策略!
【8月更文挑战第19天】在信息化时代,光纤通信至关重要,光模块作为其核心组件,其性能直接影响数据传输质量。光衰,即光信号在光纤中传输时的功率损失,是评估光模块性能的关键指标。本文将阐述光衰的基本概念、测量方法及对网络性能的影响,并提供光衰正常范围的标准,帮助网络工程师更好地理解与应用这一重要知识点,确保网络稳定可靠。
3317 0
|
数据采集 机器学习/深度学习 PyTorch
PyTorch中的数据加载与预处理
【4月更文挑战第17天】了解PyTorch中的数据加载与预处理至关重要。通过`Dataset`和`DataLoader`,我们可以自定义数据集、实现批处理、数据混洗及多线程加载。`transforms`模块用于数据预处理,如图像转Tensor和归一化。本文展示了CIFAR10数据集的加载和预处理示例,强调了这些工具在深度学习项目中的重要性。