OSPF在企业网络中的应用
一.ospf原理:
概述
ospf又称为开放最短路径优先协议,属于链路状态路由协议。这种路由协议用途广泛,通常用在大型园区企业网络中。
特点
ospf有以下几个特点:1.通常采用了触发更新,对带宽占用小,只有网络变化才通知。2.更新路由条目时,发布的是链路状态时对周边网络的描述。3.通过组播发送信息。4.meric值又称为cost,也就是说通过带宽去选择最佳路径,计算metric值是基于带宽得出来的。5.关于网络规模,ospf理论上是没有规模的限制,但实际中它的最大规模是1000台。6.在负载均衡方面,ospf是等代价的。7.收敛速度快。8.不会形成环路径9.ospf通常有三张表格,分别是邻居表、链路状态数据库、通过spf算出的路由表。10.支持可变成子网掩码。等等
二.案例
ospf多区域配置
实验要求:
1. rip网络重发布到ospf,ospf以默认路由重发布到rip
2. 在ospf1设置末节区域,路由表只有区域间路由和域内路由
3. 在ospf1设置完全末节区域,路由表显示域内路由和默认
4. 实现全网互通
实验设备要求:六台路由器 线若干
实验拓扑图:
以CISCO路由器为例:
下面为配置信息:
r1配置:
- router>en
- router#conf t
- router(config)#host r1 [为路由器起别名]
- r1(config)#inter lo0
- r1(config-if)#ip add 192.168.1.1 255.255.255.0
- r1(config-if)#inter s1/0 [进入接口配置IP地址]
- r1(config-if)#ip add 192.168.2.1 255.255.255.0
- r1(config-if)#no shut
- r1(config-if)#router ospf 10 [配置ospf协议]
- r1(config-router)#net 192.168.1.0 0.0.0.255 a 1 [ospf的网段写法,首先写出该网段的IP 地址,然后跟上该网段的反掩码,最后跟上该网段所属的area x区域]
- r1(config-router)#net 192.168.2.0 0.0.0.255 a 1
- [r1路由配置完毕]
r2配置:
- r2(config)#inter s1/0
- r2(config-if)#ip add 192.168.2.2 255.255.255.0
- r2(config-if)#no shut
- r2(config)#inter s1/1
- r2(config-if)#ip add 192.168.3.1 255.255.255.0
- r2(config-if)#no shut
- r2(config-if)#inter s1/2
- r2(config-if)#ip add 192.168.6.1 255.255.255.0
- r2(config-if)#no shut
- r2(config-if)#exit
- r2(config)#router ospf 10
- r2(config-router)#net 192.168.2.0 0.0.0.255 a 1
- r2(config-router)#net 192.168.3.0 0.0.0.255 a 0
- r2(config-router)#exit
- r2(config)#router rip [配置rip]
- r2(config-router)#net 192.168.6.0
- r2(config)#router ospf 10 [对rip协议进行重分发,在ospf 区域中学习到各个区域中的详细路由表]
- r2(config-router)#redistribute rip metric 100 subnets
- r2(config-router)#router rip [rip区域中学习到默认路由]
- r2(config-router)#default-information originate
r3配置:
- router(config)#host r3
- r3(config)#inter s1/1
- r3(config-if)#ip add 192.168.3.2 255.255.255.0
- r3(config-if)#no shut
- r3(config-if)#inter s1/0
- r3(config-if)#ip add 192.168.4.1 255.255.255.0
- r3(config-if)#no shut
- r3(config-if)#exit
- r3(config)#router ospf 10
- r3(config-router)#net 192.168.3.0 0.0.0.255 a 0
- r3(config-router)#net 192.168.4.0 0.0.0.255 a 2
- r3(config)#router ospf 10
- r3(config-router)#area 2 stub [末节区域需要在该区域的所有路由器上都声明 area x stub]
- r3(config-router)#area 2 stub no-summary [配置完全末节]
r4配置:
- router(config)#inter s1/0
- router(config-if)#ip add 192.168.4.2 255.255.255.0
- router(config-if)#no shut
- router(config-if)#inter lo0
- router(config-if)#ip add 192.168.5.1 255.255.255.0
- router(config-if)#exit
- router(config)#router ospf 10
- router(config-router)#net 192.168.4.0 0.0.0.255 a 2
- router(config-router)#net 192.168.5.0 0.0.0.255 a 2
- router(config-router)#router ospf 10
- router(config-router)#area 2 stub【设置末节区域】
r5配置:
- router(config)#inter s1/2
- router(config-if)#ip add 192.168.6.2 255.255.255.0
- router(config-if)#no shut
- router(config-if)#inter s1/0
- router(config-if)#ip add 192.168.7.1 255.255.255.0
- router(config-if)#no shut
- router(config-if)#exit
- router(config)#router rip [RIP的路由协议配置]
- router(config-router)#net 192.168.6.0 [跟上直连的网段]
- router(config-router)#net 192.168.7.0
r6配置:
- router(config)#inter s1/0
- router(config-if)#ip add 192.168.7.2 255.255.255.0
- router(config-if)#no shut
- router(config-if)#inter lo0
- router(config-if)#ip add 192.168.8.1 255.255.255.0
- router(config-if)#exit
- router(config)#router rip
- router(config-router)#net 192.168.7.0
- router(config-router)#net 192.168.8.0
实验结果:
结论:学习除了本区域,外部区域的路由均为静态默认路由。
结论:r4为完全末节区域,学习到的路由表只有自己本区域和一条直连路由。
转载于:https://blog.51cto.com/yz406/950689