先说点OSPF方面的概念:
1. OSPF协议可以运行在三种拓扑结构中:广播型多路访问(Broadcast Multi-Access)、点到点拓扑结构、非广播型多路访问(Non-Broadcast Multi-Access,NBMA),今天做的是第一个,广播型多路访问。
2. 广播型多路访问拓扑结构:这种网络具有将一个物理消息发送给所有在同一个网络上的路由器的能力,比如说以太网,在这种网络拓扑和NBMA拓扑结构下,必须给每个网段选举出DR(Designated Router)和BDR(Backup Designated Router ),即指定路由器和备份指定路由器,用它们来代表整个网络。实行BR和BDR选举来代表整个网络有两个好处:1)减少路由更新数据流。在多路访问网络环境中,多台路由器可以互为邻居,如果它们之间都建立相邻关系并相互交换链路状态信息,则关系复杂,数据流量大。而选举了BR和DBR之后,每台路由器都只与DR和BDR建立相邻关系和交换链路状态信息,这种扩散过程大大减小了网络上的数据流量。
2)管理链路状态同步。DR和BDR可以保证网络上的其他路由器得到的链路状态信息都是一样的(达到同步)。
关于OSPF的相关概念还有很多,比如说它的启动过程,选举DR和BDR的规则和选举的时间,还有就是路由信息的更新和维护,这里就不在打出来了,下面是我的实验拓扑图:
配置过程如下:
一.先配置好pc0和pc1的IP地址,网关地址。
二.配置三个路由器各个接口的IP地址,并启用:
Router0:
Router#conf t
Router(config)#hostname r0
r0(config)#interface fa0/0
r0(config-if)#ip address 192.168.1.2 255.255.255.0
r0(config-if)#no shut
r0(config-if)#int fa0/1
r0(config-if)#ip add 192.168.2.1 255.255.255.0
r0(config-if)#no shut
Router1:
Router>en
Router#conf t
Router(config)#hostname r1
r1(config)#int fa0/0
r1(config-if)#ip address 192.168.2.2 255.255.255.0
r1(config-if)#no shut
r1(config-if)#int fa 0/1
r1(config-if)#ip add 192.168.3.1 255.255.255.0
r1(config-if)#no shut
Router2:
Router>en
Router#conf t
Router(config)#hostname r2
r2(config)#int fa0/0
r2(config-if)#ip add 192.168.3.2 255.255.255.0
r2(config-if)#no shut
r2(config-if)#int fa0/1
r2(config-if)#ip add 192.168.4.1 255.255.255.0
r2(config-if)#no shut
三.在三个路由器上分别启用ospf协议:
Router0:
r0(config-if)#router ospf 1
//1表示的是路由器上运行的不同的ospf进程号,不需要和其他路由器上的进程号相同。
r0(config-router)#network 192.168.1.0 0.0.0.255 area 0
//指示路由器的哪些接口运行在哪个区域内,目前还是单域实验,所以所有的接口都运行在同一个area里面,此处都运行在area 0中。
r0(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router1:
r1(config)#router ospf 2
r1(config-router)#network 192.168.3.0 0.0.0.255 area 0
r1(config-router)#network 192.168.2.0 0.0.0.255 area 0
Router2:
r2(config)#router ospf 3
r2(config-router)#network 192.168.3.0 0.0.0.255 area 0
r2(config-router)#network 192.168.4.0 0.0.0.255 area 0
四.检查ospf的运行:
1.pc0 ping pc4:
2.pc4 ping pc0:
3.
r0#show ip protocols
Routing Protocol is "ospf 1" //路由器上运行ospf协议,进程号1
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.2.1 //本路由器ID
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4 //最多支持4条等值路由
Routing for Networks:
192.168.1.0 0.0.0.255 area 0
192.168.2.0 0.0.0.255 area 0
Routing Information Sources:
Gateway Distance Last Update
192.168.2.2 110 00:01:52
Distance: (default is 110) //ospf默认管理距离为110
4.
r0#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, FastEthernet0/1
O 192.168.3.0/24 [110/2] via 192.168.2.2, 00:02:54, FastEthernet0/1
O 192.168.4.0/24 [110/3] via 192.168.2.2, 00:02:54, FastEthernet0/1
5.
r0#show ip ospf neighbor
Neighbor ID Pri State Dead Time Address Interface
192.168.3.1 1 FULL/BDR 00:00:36 192.168.2.2 FastEthernet0/1 //显示出r2被选举成为了BDR
6.
r0#show ip ospf interface
FastEthernet0/0 is up, line protocol is up
Internet address is 192.168.1.2/24, Area 0
Process ID 1, Router ID 192.168.2.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.2.1, Interface address 192.168.1.2
No backup designated router on this network
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:09
Index 1/1, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 0, Adjacent neighbor count is 0
Suppress hello for 0 neighbor(s)
FastEthernet0/1 is up, line protocol is up
Internet address is 192.168.2.1/24, Area 0
Process ID 1, Router ID 192.168.2.1, Network Type BROADCAST, Cost: 1
Transmit Delay is 1 sec, State DR, Priority 1
Designated Router (ID) 192.168.2.1, Interface address 192.168.2.1
Backup Designated Router (ID) 192.168.3.1, Interface address 192.168.2.2
Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5
Hello due in 00:00:06
Index 2/2, flood queue length 0
Next 0x0(0)/0x0(0)
Last flood scan length is 1, maximum is 1
Last flood scan time is 0 msec, maximum is 0 msec
Neighbor Count is 1, Adjacent neighbor count is 1
Adjacent with neighbor 192.168.2.2 (Backup Designated Router)
Suppress hello for 0 neighbor(s)
7.使用show ip ospf database命令查看路由器的ospf链路状态数据库
r0#show ip ospf database
OSPF Router with ID (192.168.2.1) (Process ID 1)
Router Link States (Area 0)
Link ID ADV Router Age Seq# Checksum Link count
192.168.4.1 192.168.4.1 623 0x80000003 0x005cbe 2
192.168.2.1 192.168.2.1 612 0x80000003 0x0034f1 2
192.168.3.1 192.168.3.1 612 0x80000004 0x00b6fa 2
Net Link States (Area 0)
Link ID ADV Router Age Seq# Checksum
192.168.3.2 192.168.4.1 623 0x80000001 0x001c4a
192.168.2.1 192.168.2.1 612 0x80000001 0x004e5b
实验总结:ospf能够解决许多距离矢量型路由协议所不能解决的问题,适用于大型网络,但它的这些特点也为ospf协议的网络带来了复杂性,现在只是ospf协议在单域环境下的运行,多域环境下会更复杂的。
欢迎访问最专业的网吧论坛,无盘论坛,网吧经营,网咖管理,网吧专业论坛https://bbs.txwb.com |
关注天下网吧微信,了解网吧网咖经营管理,安装维护:
本文来源:中国网管学院 作者:佚名