通过本实验可以掌握:
1. 在路由器上启动ospf路由进程
2. 启用参与路由协议的接口,并且通告网络及所在的区域
3. 度量值Cost的计算
4. 查看和调试路由协议相关信息
拓扑图如下:
技术要点:
1 ospf 路由进程ID的范围必须地1~65535之间,而且只有本地含义,不同路由器的路由进程ID可以不同,如果要想启动ospf路由进程,至少确保有一个接口是up的状态,
2 区域ID是在0~4294967295内的十进制数,也可以是IP地址的格式a.b.c.d
当网络区域ID 为0或0.0.0.0时称为主区域。
3在高版本的ios中通告ospf网络的时候,网络号的后面可以是跟网络掩码,也可以跟反码。
4 确定Router ID 遵循如下顺序:
最优先的是在ospf进程中用命令“route-id”指定路由器id。
如果没有在ospf进程中指定路由器id,那么选择ip地址最大的环回接口的ip地址为Router ID.
如果没有环回接口,就选择最大活动的物理接口的ip地址为Router ID
建议用命令“router-ip”,来指定路由器ID,这样可控制性比较好。
具体步骤:
对于R0:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R0
R0(config)#int s2/0
R0(config-if)#ip add 192.168.1.1 255.255.255.0
R0(config-if)#clock rate 9600 ß设置时钟频率
R0(config-if)#no shut
R0(config-if)#exit
R0(config)#router ospf 1
R0(config-router)#router
R0(config-router)#router-id 1.1.1.1
R0(config-router)#network 1.1.1.0 0.0.0.255 area 0
R0(config-router)#network 192.168.1.0 0.0.0.255 area 0
对于R1:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R
Router(config)#hostname R1
R1(config)#int s3/0
R1(config-if)#ip add 192.168.1.2 255.255.255.0
R1(config-if)#no shut
R1(config-if)#int s2/0
R1(config-if)#ip add 192.168.2.1 255.255.255.0
R1(config-if)#clock rate 9600
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router ospf 1
R1(config-router)#router
R1(config-router)#router-id 2.2.2.2
R1(config-router)#network 2.2.2.0 0.0.0.255
R1(config-router)#network 2.2.2.0 0.0.0.255 area 0
R1(config-router)#network 192.168.1.0 0.0.0.255 area 0
R1(config-router)#network 192.168.2.0 0.0.0.255 area 0
对于R2:
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#int s3/0
R2(config-if)#ip add 192.168.2.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#int s2/0
R2(config-if)#ip add 192.168.3.1 255.255.255.0
R2(config-if)#clock rate 9600
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router ospf 1
R2(config-router)#router-id 3.3.3.3
R2(config-router)#network 3.3.3.0 0.0.0.255 area 0
R2(config-router)#network 192.168.2.0 0.0.0.255 area 0
R2(config-router)#network 192.168.3.0 0.0.0.255 area 0
对于R3:
R3(config)#int s3/0
R3(config-if)#ip add 192.168.3.2 255.255.255.0
R3(config-if)#no shut
R3(config-if)#exit
R3(config)#router ospf 1
R3(config-router)#router-id 4.4.4.4
R3(config-router)#network 4.4.4.0 0.0.0.255 area 0
R3(config-router)#network 192.168.3.0 0.0.0.255 area 0
实验调试:
在R0上:
R0#ping 192.168.3.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.3.2, timeout is 2 seconds:
!!!!! ß可以看到R0与R4已经能够通讯了
Success rate is 100 percent (5/5), round-trip min/avg/max = 50/81/94 ms
在R1上:
R1#show ip route
。。。。。。。。
C 192.168.1.0/24 is directly connected, Serial3/0
C 192.168.2.0/24 is directly connected, Serial2/0
O 192.168.3.0/24 [110/1562] via 192.168.2.2, 00:39:27, Serial2/0
R1#show ip protocols
Routing Protocol is "ospf 1"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 2.2.2.2 //本路由器ID
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
//默认支持等价路径最大数目
Routing for Networks:
2.2.2.0 0.0.0.255 area 0
192.168.1.0 0.0.0.255 area 0
192.168.2.0 0.0.0.255 area 0
//以上4行表明ospf通告的网络以及这些网络所在的区域。
Routing Information Sources:
Gateway Distance Last Update
192.168.1.1 110 00:01:21
192.168.2.2 110 00:01:21
//以上表明路由信息源
Distance: (default is 110) //ospf路由协议默认的管理距离。
R1#show ip ospf
Routing Process "ospf 1" with ID 2.2.2.2
Supports only single TOS(TOS0) routes
。。。。。
在R3上:
R3#ping 192.168.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 93/93/94 ms
可以看到R0与R3已经通了