OSPF(开放最短链路优先)路由协议是典型的链路状态路由协议。

OSPF作为一种内部路由协议(IGP)用于在同一个自治系统(AS)中的路由器之间交换路由信息。特点是:

1.可适应大规模网络;

2.收敛速度快;

3.无路由环路;

4.支持VLSM,CIDR;

5.支持等价路由;

6.支持区域划分,构成结构化网络;

7.提供路由分级管理;

8.支持简单口令和MD5认证;

9.以组播的方式传送协议报文;

10.管理距离110;

11.采用cost作为度量标准;

12.ospf维护邻居表。拓扑表。路由表;

ospf将网络划分为四种类型:广播多路访问型(BMA).非广播多路访问型(NBMA),点到点型(point-to-point)。点到多点型(point-to-multipoint)不同的二层链路的类型需要ospf不同的网络类型来适应。

LSA:链路状态通告

SPF:最短路径优先算法

 

实验:点到点链路上的ospf。

实验拓扑:

OSPF - 壁虎 - Me~~study house!
实验步骤:
R1:
enable
conf t
no ip domain-lookup
line cons 0
logging synchronous
exit
int s1/0
clock rate 64000
ip add 192.168.12.1 255.255.255.0
no shut
int lo0
ip add 1.1.1.1 255.255.255.0
exit
router ospf 1
router-id 1.1.1.1                                 //指定路由器ID
net 192.168.12.0 0.0.0.255 area 0
net 1.1.1.0 0.0.0.255 area 0
area 0 authentication(message-digest)                      //区域0 启用简单口令认证(MD5认证)
int s1/0
ip ospf authentication-key cisco   //配置认证密码             (基于区域的简单、MD5口令认证)
(ip ospf message-digest-key 1 md5 cisco)           //配置认证ID及密钥
end
 
 
R2:
enable
conf t
no ip domain-lookup
line cons 0
logging synchronous
exit
int lo0
ip add 2.2.2.2 255.255.255.0
int s1/0
ip add 192.168.12.2 255.255.255.0
no shut
int s1/1
ip add 192.168.23.2 255.255.255.0
clock rate 64000
no shut
exit
router ospf 1
router-id 2.2.2.2
net 2.2.2.0 0.0.0.255 area 0
net 192.168.12.0 0.0.0.255 area 0
net 192.168.23.0 0.0.0.255 area 0
area 0 authentication(message-digest)                      //区域0 启用简单口令认证(MD5认证)
int s1/0
ip ospf authentication-key cisco   //配置认证密码             (基于区域的简单、MD5口令认证)
(ip ospf message-digest-key 1 md5 cisco)           //配置认证ID及密钥
end
 
 
R3:
enable
conf t
no ip domain-lookup
line cons 0
logging synchronous
exit
int lo0
ip add 3.3.3.3 255.255.255.0
int s1/1
ip add 192.168.23.3 255.255.255.0
no shut
int s1/2
clock rate 64000
ip add 192.168.34.3 255.255.255.0
no shut
exit
router ospf 1
router-id 3.3.3.3
net 192.168.23.0 0.0.0.255 area 0
net 192.168.34.0 0.0.0.255 area 0
net 3.3.3.0 0.0.0.255 area 0
end
 
 
R4
enable
conf t
no ip domain-lookup
line cons 0
logging synchronous
exit
int lo0 4.4.4.4 255.255.255.0
int s1/2
ip add 192.168.34.4 255.255.255.0
no shut
exit
router ospf 1
router-id 4.4.4.4
net 4.4.4.0 0.0.0.255 area 0
net 192.168.34.0 0.0.0.255 area 0
end
 
这时全网互通!!!
下面面看一下R2的路由表
show ip route
OSPF - 壁虎 - Me~~study house!
以O开头的代表通过ospf学习来的地址!
 
show  ip  ospf  neighbor 来查看邻居表!
 
DR。BDR介绍和选举

OSPF - 壁虎 - Me~~study house!

 
 

 ospf命令汇总:

 

 

OSPF - 壁虎 - Me~~study house!OSPF - 壁虎 - Me~~study house!