ospf在企业网中的应用

 

一、 ospf原理及简介
 ospf( Open Shortest Path First)是一种内部网管协议( IGP),是基于链路状态的动态路由协议,属于单个自治体系( AS)的路由器之间的路由选择,每个ospf维护相同自治系统拓扑结构的数据库。“最短路径优先”是该协议路由计算时执行的算法。它直接在IP层进行传输,协议号为89。
它具有一下特点:
1.      无路由环路
2.      触发更新
3.      路由变化收敛速度快
4.      支持可变长子网掩码( vlsm)
5.      支持以组播地址发送协议报文
6.      支持区域划分
7.      适应大规模的网络
 
OSPF在工作中实在维持着三张表。
   OSPF的邻居表
   OSPF的拓扑表
   OSPF的路由表
 
邻居表(邻居关系数据库):与自己直连的所有路由器的记录信息。
 拓扑表(拓扑数据库、链路状态数据库):记录所有目的网段结构的信息。
 路由表:转发数据表。
 
二、案例
1、实验拓扑图:
 

2、实验环境说明
在上述拓扑图中黄色区域为 area 1区域,并设置为末节区域,绿色区域为area 0区域,红色区域为area 2区域,深绿色区域为area 3区域,并设置为完全末节区域,由于area 0和area 3没有直接相连,在area 0和area 3之间配置一条虚拟链路。蓝色区域为rip区域。通过路由充分发,实现不同路由协议间区域互通。
三、实验步骤
1.R1的配置
 
interface FastEthernet0/0
ip address 192.168.1.1 255.255.255.0
interface Serial1/0
ip address 192.168.2.1 255.255.255.0
接口配置
router ospf 10
log-adjacency-changes
area 1 stub
network 192.168.1.0 0.0.0.255 area 1
network 192.168.2.0 0.0.0.255 area 1
配置路由
R1(config-router)#area 1 stub 设置末节区域
O IA 192.168.8.0/24 [110/385] via 192.168.2.2, 01:14:41, Serial1/0
O IA 192.168.4.0/24 [110/192] via 192.168.2.2, 01:24:26, Serial1/0
O IA 192.168.5.0/24 [110/256] via 192.168.2.2, 01:24:26, Serial1/0
O IA 192.168.6.0/24 [110/320] via 192.168.2.2, 01:24:26, Serial1/0
O IA 192.168.7.0/24 [110/384] via 192.168.2.2, 01:24:26, Serial1/0
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, Serial1/0
O 192.168.3.0/24 [110/128] via 192.168.2.2, 01:24:26, Serial1/0
O*IA 0.0.0.0/0 [110/129] via 192.168.2.2, 01:24:26, Serial1/0
r1的路由信息
   测试: 

 
 
2、R2的配置    
 
interface Serial1/0
ip address 192.168.2.2 255.255.255.0
interface Serial1/1
ip address 192.168.3.1 255.255.255.0 
  接口配置
router ospf 10
log-adjacency-changes
area 1 stub
network 192.168.2.0 0.0.0.255 area 1
network 192.168.3.0 0.0.0.255 area 1  
配置路由
R2(config-router)#area 1 stub           配置末节区域
O IA 192.168.8.0/24 [110/321] via 192.168.3.2, 01:27:29, Serial1/1
O IA 192.168.4.0/24 [110/128] via 192.168.3.2, 01:37:17, Serial1/1
O IA 192.168.5.0/24 [110/192] via 192.168.3.2, 01:37:17, Serial1/1
O IA 192.168.6.0/24 [110/256] via 192.168.3.2, 01:37:16, Serial1/1
O IA 192.168.7.0/24 [110/320] via 192.168.3.2, 01:37:16, Serial1/1
O 192.168.1.0/24 [110/65] via 192.168.2.1, 01:37:17, Serial1/0
C 192.168.2.0/24 is directly connected, Serial1/0
C 192.168.3.0/24 is directly connected, Serial1/1
O*IA 0.0.0.0/0 [110/65] via 192.168.3.2, 01:37:17, Serial1/1
  R2上的路由信息
3、R3的配置
interface Serial1/0
ip address 192.168.4.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.3.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/2
ip address 192.168.9.1 255.255.255.0 接口信息
serial restart-delay 0
!
interface Serial1/3
no ip address
shutdown
serial restart-delay 0
!
router ospf 10
log-adjacency-changes
area 1 stub             设置末节区域
redistribute rip        分发动态路由
network 192.168.3.0 0.0.0.255 area 1
network 192.168.4.0 0.0.0.255 area 0   配置路由
!
router rip
network 192.168.9.0
default-information originate    
重分发默认路由
O IA 192.168.8.0/24 [110/257] via 192.168.4.2, 01:38:08, Serial1/0
C 192.168.9.0/24 is directly connected, Serial1/2
R 192.168.10.0/24 [120/1] via 192.168.9.2, 00:00:03, Serial1/2
R 192.168.11.0/24 [120/2] via 192.168.9.2, 00:00:03, Serial1/2
C 192.168.4.0/24 is directly connected, Serial1/0
O IA 192.168.5.0/24 [110/128] via 192.168.4.2, 01:47:52, Serial1/0
O IA 192.168.6.0/24 [110/192] via 192.168.4.2, 01:47:52, Serial1/0
O IA 192.168.7.0/24 [110/256] via 192.168.4.2, 01:47:52, Serial1/0
O 192.168.1.0/24 [110/129] via 192.168.3.1, 01:47:52, Serial1/1
O 192.168.2.0/24 [110/128] via 192.168.3.1, 01:47:52, Serial1/1
C 192.168.3.0/24 is directly connected, Serial1/1
  R3路由信息
4、R4的配置
interface Serial1/0
ip address 192.168.4.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 192.168.5.1 255.255.255.0
serial restart-delay 0                      接口配置
!

router ospf 10
log-adjacency-changes 
area 2 virtual-link 192.168.7.1        设置虚拟链路
network 192.168.4.0 0.0.0.255 area 0
network 192.168.5.0 0.0.0.255 area 2   
配置路由
O IA 192.168.8.0/24 [110/193] via 192.168.5.2, 01:45:01, Serial1/1
O E2 192.168.9.0/24 [110/20] via 192.168.4.1, 01:57:53, Serial1/0
O E2 192.168.10.0/24 [110/20] via 192.168.4.1, 01:57:53, Serial1/0
O E2 192.168.11.0/24 [110/20] via 192.168.4.1, 01:57:53, Serial1/0
C 192.168.4.0/24 is directly connected, Serial1/0
C 192.168.5.0/24 is directly connected, Serial1/1
O 192.168.6.0/24 [110/128] via 192.168.5.2, 01:58:03, Serial1/1
O IA 192.168.7.0/24 [110/192] via 192.168.5.2, 01:57:53, Serial1/1
O IA 192.168.1.0/24 [110/193] via 192.168.4.1, 01:54:45, Serial1/0
O IA 192.168.2.0/24 [110/192] via 192.168.4.1, 01:54:45, Serial1/0
O IA 192.168.3.0/24 [110/128] via 192.168.4.1, 01:57:53, Serial1/0

                                                                   R4的路由信息
5、R5的配置
interface Serial1/0
ip address 192.168.6.1 255.255.255.0
interface Serial1/1
ip address 192.168.5.2 255.255.255.0             接口配置
router ospf 10
log-adjacency-changes
network 192.168.5.0 0.0.0.255 area 2
network 192.168.6.0 0.0.0.255 area 2         
配置路由
O IA 192.168.8.0/24 [110/129] via 192.168.6.2, 01:47:13, Serial1/0
O E2 192.168.9.0/24 [110/20] via 192.168.5.1, 02:00:05, Serial1/1
O E2 192.168.10.0/24 [110/20] via 192.168.5.1, 02:00:05, Serial1/1
O E2 192.168.11.0/24 [110/20] via 192.168.5.1, 02:00:05, Serial1/1
O IA 192.168.4.0/24 [110/128] via 192.168.5.1, 02:00:11, Serial1/1
C 192.168.5.0/24 is directly connected, Serial1/1
C 192.168.6.0/24 is directly connected, Serial1/0
O IA 192.168.7.0/24 [110/128] via 192.168.6.2, 02:00:06, Serial1/0
O IA 192.168.1.0/24 [110/257] via 192.168.5.1, 01:56:57, Serial1/1
O IA 192.168.2.0/24 [110/256] via 192.168.5.1, 01:56:57, Serial1/1
O IA 192.168.3.0/24 [110/192] via 192.168.5.1, 02:00:11, Serial1/1
                                          R5上的路由信息
6、R6的配置
interface Serial1/0
ip address 192.168.6.2 255.255.255.0

interface Serial1/1
ip address 192.168.7.1 255.255.255.0           接口配置

router ospf 10
log-adjacency-changes
area 2 virtual-link 192.168.5.1              设置虚拟链路
area 3 stub no-summary                设置完全末节区域
network 192.168.6.0 0.0.0.255 area 2
network 192.168.7.0 0.0.0.255 area 3          
配置路由
O 192.168.8.0/24 [110/65] via 192.168.7.2, 01:50:59, Serial1/1
O E2 192.168.9.0/24 [110/20] via 192.168.6.1, 01:50:59, Serial1/0
O E2 192.168.10.0/24 [110/20] via 192.168.6.1, 01:50:59, Serial1/0
O E2 192.168.11.0/24 [110/20] via 192.168.6.1, 01:50:59, Serial1/0
O 192.168.4.0/24 [110/192] via 192.168.6.1, 01:52:12, Serial1/0
O 192.168.5.0/24 [110/128] via 192.168.6.1, 01:52:12, Serial1/0
C 192.168.6.0/24 is directly connected, Serial1/0
C 192.168.7.0/24 is directly connected, Serial1/1
O IA 192.168.1.0/24 [110/321] via 192.168.6.1, 01:50:59, Serial1/0
O IA 192.168.2.0/24 [110/320] via 192.168.6.1, 01:50:59, Serial1/0
O IA 192.168.3.0/24 [110/256] via 192.168.6.1, 01:50:59, Serial1/0

                                                                                           R6上的路由信息
7、R7上的配置
interface FastEthernet0/0
ip address 192.168.8.1 255.255.255.0
loopback
interface Serial1/1
ip address 192.168.7.2 255.255.255.0           接口配置

router ospf 10
log-adjacency-changes
area 3 stub no-summary                 配置完全末节区域
network 192.168.7.0 0.0.0.255 area 3
network 192.168.8.0 0.0.0.255 area 3   
配置路由
R7#show ip route                       R7上的路由信息
C 192.168.8.0/24 is directly connected, FastEthernet0/0
C 192.168.7.0/24 is directly connected, Serial1/1
O*IA 0.0.0.0/0 [110/65] via 192.168.7.1, 01:55:41, Serial1/1
测试:
 

 
8、R8的配置
interface Serial1/0
ip address 192.168.10.1 255.255.255.0
interface Serial1/2
ip address 192.168.9.2 255.255.255.0 接口配置

router rip
network 192.168.9.0
network 192.168.10.0                 
路由配置
R8#show ip route                  R8 的路由信息
C 192.168.9.0/24 is directly connected, Serial1/2
C 192.168.10.0/24 is directly connected, Serial1/0
R 192.168.11.0/24 [120/1] via 192.168.10.2, 00:00:10, Serial1/0
R* 0.0.0.0/0 [120/1] via 192.168.9.1, 00:00:06, Serial1/2
9、R9的配置
interface FastEthernet0/0
ip address 192.168.11.1 255.255.255.0
loopback
interface Serial1/0
ip address 192.168.10.2 255.255.255.0    接口配置

router rip
network 192.168.10.0
network 192.168.11.0            
配置路由
R9#show ip route               R9上的路由信息
R 192.168.9.0/24 [120/1] via 192.168.10.1, 00:00:20, Serial1/0
C 192.168.10.0/24 is directly connected, Serial1/0
C 192.168.11.0/24 is directly connected, FastEthernet0/0
R* 0.0.0.0/0 [120/2] via 192.168.10.1, 00:00:20, Serial1/0
测试:
 

 
三、总结
华为设备上的配置与 cisco 类似.

你可能感兴趣的:(ospf)