0
点赞
收藏
分享

微信扫一扫

ospf路由协议

开放式最短路径优先协议(Open Shortest Path First,OSPF)是基于开放标准的链路状态路由选择协议,它完成各路由选择协议算法的两大主要功能:路径选择和路径交换。

OSPF是链路状态路由协议

距离矢量路由协议中,路由器之间互相传递路由表信息来学习路由信息,距离矢量协议的路由器只知道某个网段可以通过哪个下一跳到达和到达这个网络有多远等这样的信息,并不了解整个网络的拓扑结构。

链路状态路由协议通过与邻居路由器建立邻接关系,互相传递链路状态信息,来了解整个网络的拓扑结构。在链路状态信息中,包含哪些链路,这些链路与哪个路由器相连,来了解整个网络的拓扑结构。

内部网关协议与外部网关协议

自治系统(AS)

内部网关协议(IGP)

RIP、OSPF

外部网关协议(EGP)

BGP

OSPF的工作过程

运行RIP路由协议的路由只需要保存一张路由表,而使用OSPF路由协议的路由器需要保存一下三张表。

邻居列表:列出每台路由器已经建立邻接关系的全部邻居路由器。

链路状态数据库(LSDB):列出网络中其他路由器的信息,由此显示了全网的网络拓扑。

路由表:列出通过Dijkstra算法计算出的到达每个相连网络最佳路径。

OSPF路由协议路由表形成的过程

1.建立邻接关系(学习链路状态信息)----->2.链路状态数据库(Dijkstra算法,Dijkstra最短路径算法的创造者。或者SPF,最短路径优先算法。)------->3.最短路径树----->路由表


使用动态路由协议ospf配置以下拓扑

ospf路由协议_链路 IP地址规划如下:

IOU1

Ethernet0/0:192.168.12.1/24


Ethernet0/1:192.168.13.1/24


loopback0:1.1.1.1/32

IOU2

Ethernet0/0:192.168.12.2/24


Ethernet0/1:192.168.24.2/24


loopback0:2.2.2.2/32

IOU3

Ethernet0/0:192.168.13.3/24


Ethernet0/1:192.168.34.3/24


loopback0:3.3.3.3/32

IOU4

Ethernet0/0:192.168.24.4/24


Ethernet0/1:192.168.34.4/24


loopback0:4.4.4.4/32

IOU1上的配置

IOU1#configure terminal
IOU1(config)#interface ethernet 0/0
IOU1(config-if)#ip address 192.168.12.1 255.255.255.0
IOU1(config-if)#no shutdown
IOU1(config-if)#exit
IOU1(config)#interface ethernet 0/1
IOU1(config-if)#ip address 192.168.13.1 255.255.255.0
IOU1(config-if)#no shutdown
IOU1(config-if)#exit
IOU1(config)#interface loopback 0
IOU1(config-if)#ip address 1.1.1.1 255.255.255.255
IOU1(config-if)#exit

使用show ip interface brief命令查看IOU1接口的状态

ospf路由协议_路由协议_02

IOU2上的配置

IOU2#configure terminal
IOU2(config)#interface ethernet 0/0
IOU2(config-if)#ip address 192.168.12.2 255.255.255.0
IOU2(config-if)#no shutdown
IOU2(config-if)#exit
IOU2(config)#interface ethernet 0/1
IOU2(config-if)#ip address 192.168.24.2 255.255.255.0
IOU2(config-if)#no shutdown
IOU2(config-if)#exit
IOU2(config)#interface loopback 0
IOU2(config-if)#ip address 2.2.2.2 255.255.255.255
IOU2(config-if)#no shutdown
IOU2(config-if)#exit

使用show ip interface brief命令查看IOU2接口的状态

ospf路由协议_路由表_03

IOU3上的配置

IOU3#configure terminal
IOU3(config)#interface ethernet 0/0
IOU3(config-if)#ip address 192.168.13.3 255.255.255.0
IOU3(config-if)#no shutdown
IOU3(config-if)#exit
IOU3(config)#interface ethernet 0/1
IOU3(config-if)#ip address 192.168.34.3 255.255.255.0
IOU3(config-if)#no shutdown
IOU3(config-if)#exit
IOU3(config)#interface loopback 0
IOU3(config-if)#ip address 3.3.3.3 255.255.255.255
IOU3(config-if)#exit

使用show ip interface brief命令查看IOU3接口的状态

ospf路由协议_链路_04

IOU4上的配置

IOU4#configure terminal
IOU4(config)#interface ethernet 0/1
IOU4(config-if)#ip address 192.168.34.4 255.255.255.0
IOU4(config-if)#no sh
IOU4(config-if)#no shutdown
IOU4(config-if)#exit
IOU4(config)#interface ethernet 0/0
IOU4(config-if)#ip address 192.168.24.4 255.255.255.0
IOU4(config-if)#no shutdown
IOU4(config-if)#exit
IOU4(config)#interface loopback 0
IOU4(config-if)#ip address 4.4.4.4 255.255.255.255
IOU4(config-if)#exit

使用show ip interface brief命令查看IOU4接口的状态

ospf路由协议_路由协议_05

配置OSPF,全部都配置area0(骨干区域)

OSPF区域

为了适应大型的网络,OSPF在AS内划分多个区域

每个OSPF路由器只维护所在区域的完整链路状态信息

区域ID

区域ID可以表示成一个十进制的数字

与可以表示成一个IP

骨干区域Area 0

负责区域间路由信息传播

IOU1上的配置

IOU1(config)#router ospf 1
IOU1(config-router)#router-id 1.1.1.1
IOU1(config-router)#network 1.1.1.1 0.0.0.0 area 0
IOU1(config-router)#network 192.168.12.0 0.0.0.255 area 0
IOU1(config-router)#network 192.168.13.0 0.0.0.255 area 0
IOU1(config-router)#exit

OU2上的配置

IOU2(config)#router ospf 1
IOU2(config-router)#network 2.2.2.2 0.0.0.0 area 0
IOU2(config-router)#network 192.168.12.2 0.0.0.0 area 0
IOU2(config-router)#network 192.168.24.0 0.0.0.255 area 0
IOU2(config-router)#exit

OU3上的配置

IOU3(config)#router ospf 1
IOU3(config-router)#router-id 10.0.0.1
IOU3(config-router)#network 192.168.13.0 0.0.0.255 area 0
IOU3(config-router)#network 192.168.24.0 0.0.0.255 area 0
IOU3(config-router)#network 3.3.3.3 0.0.0.0 area 0
IOU3(config-router)#exit

OU4上的配置​


IOU4(config)#router ospf 1
IOU4(config-router)#network 4.4.4.4 0.0.0.0 area 0
IOU4(config-router)#network 192.168.24.0 0.0.0.255 area 0
IOU4(config-router)#network 192.168.34.0 0.0.0.255 area 0
IOU4(config-router)#exit

在IOU1上使用show ip route 查看路由表

ospf路由协议_链路_06

在IOU1上使用show ip ospf neighbor查看邻接关系表

ospf路由协议_路由表_07

使用命令ping测试网络连通性

ospf路由协议_链路_08


举报

相关推荐

0 条评论