实验四静/动态路由设置
一、 实验目的
1. 学习静待路由配置方法,理解路由器的工作原理
2. 了解路由器的RIP路由协议的原来;
3. 熟悉掌握路由器的RIP路由协议的配置方法;
4. 了解路由器的OSPF路由协议的原来;
5. 熟悉掌握路由器的OSPF路由协议的配置方法。
二、 实验内容
1. 根据拓扑图链接好所有设备;
2. 综合使用路由器和主机进行静态路由方案的设计;
3. 使用超级终端进行路由配置;
4. 使用PIP路由协议配置路由器的动态路由;
5. 使用OSPF路由协议配置路由器的 动态路由;
6. 相关命令:
#shiow ip protocols: 显示路由的路由信息
#show ip route: 显示IP路由表
静态路由:
(config-if)#ip address<本端口IP地址><子网掩码>:为端口设置一个IP地址
(config)#ip route<目的子网地址><子网掩码><相邻路由器端口地址或者本地物理端口号>:设置静态路由
(config)#no ip route<目的子网掩码><子网掩码><相邻路由器端口地址或本地物理端口号>:删除静态路由
RIP:
(config)#router rip:激活RIP路由协议
(config-router)#network<>网段地址>:指明相关联的网段,以便RIP动态学习路由信息
OSPF:
(config)#router ospf<进程号>:激活OSPF路由协议
(config-router)#network<与本路由器相连的ip子网号><通配符>area<区域号>
三、 实验条件:
如图搭建实验环境。
四、 实验过程
1) 配置静态路由:
R2600A#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, Ethernet0/0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
R2600A#config(设置静态路由)
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2600A(config)#ip route 192.168.4.0 255.255.255.0 192.168.3.2
R2600A(config)#ip route 192.168.5.0 255.255.255.0 192.168.3.2
R2600A(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
R2600A#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, Ethernet0/0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
S 192.168.4.0/24 [1/0] via 192.168.3.2
S 192.168.5.0/24 [1/0] via 192.168.3.2
R2600A#
对于路由器S2600B进行类似的配合,路由信息如下:
R2600B#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
S 192.168.1.0/24 [1/0] via 192.168.3.1
S 192.168.2.0/24 [1/0] via 192.168.3.1
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, Ethernet0/0/0
C 192.168.5.0/24 is directly connected, Ethernet0/1/0
R2600B#
在PC1上检测连通性,如下:
R2600A#config(删除路由器A静态路由)
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2600A(config)#no ip route 192.168.4.0 255.255.255.0
R2600A(config)#no ip route 192.168.5.0 255.255.255.0
R2600A(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
R2600A#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, Ethernet0/0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
R2600A#
对于路由器B也进行类似操作,请参考路由器A。
2) 配置RIP路由协议:
对路由器A:
R2600A(config)#no route rip
R2600A#exit
R2600A#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2600A(config)#router rip
R2600A(config-router)#network 192.168.1.0
R2600A(config-router)#network 192.168.2.0
R2600A(config-router)#network 192.168.3.0
R2600A(config-router)#end
%SYS-5-CONFIG_I: Configured from console by console
R2600A#show ip protocols(查看路由器A RIP协议的相关信息)
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 7 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 1, receive any version
Interface Send Recv Triggered RIP Key-chain
Ethernet0/0/0 1 2 1
Ethernet0/1/0 1 2 1
FastEthernet0/0 1 2 1
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
192.168.1.0
192.168.2.0
192.168.3.0
Passive Interface(s):
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 120)
对路由器B进行类似的配置,RIP协议的相关信息如下:
R2600B#show ip protocols(查看路由器B RIP协议的相关信息)
Routing Protocol is "rip"
Sending updates every 30 seconds, next due in 20 seconds
Invalid after 180 seconds, hold down 180, flushed after 240
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Redistributing: rip
Default version control: send version 1, receive any version
Interface Send Recv Triggered RIP Key-chain
FastEthernet0/0 1 2 1
Ethernet0/0/0 1 2 1
Ethernet0/1/0 1 2 1
Automatic network summarization is in effect
Maximum path: 4
Routing for Networks:
192.168.3.0
192.168.4.0
192.168.5.0
Passive Interface(s):
Routing Information Sources:
Gateway Distance Last Update
192.168.3.1 120 00:00:25
Distance: (default is 120)
Routing Protocol is "ospf 100"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.5.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.0.0.0 0.255.255.255 area 200
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 110)
分别查看路由器A、B的动态路由表
R2600A#show ip route(路由器A的动态路由表)
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, Ethernet0/0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
R 192.168.4.0/24 [120/1] via 192.168.3.2, 00:00:15, FastEthernet0/0
R 192.168.5.0/24 [120/1] via 192.168.3.2, 00:00:15, FastEthernet0/0
R2600A#
R2600B#show ip route(路由器B的动态路由表)
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
R 192.168.1.0/24 [120/1] via 192.168.3.1, 00:00:00, FastEthernet0/0
R 192.168.2.0/24 [120/1] via 192.168.3.1, 00:00:00, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, Ethernet0/0/0
C 192.168.5.0/24 is directly connected, Ethernet0/1/0
R2600B#在PC1上检测连通性,结果如下:
删除路由器A、B的RIP路由设置:
R2600A#no router rip
R2600B#no router rip
3) 配置OSPF路由协议:
对路由器A:
R2600A#config
Configuring from terminal, memory, or network [terminal]?
Enter configuration commands, one per line. End with CNTL/Z.
R2600A(config)#router ospf 100
R2600A(config-router)#network 192.168.1.0 0.255.255.255 area 200
R2600A(config-router)#network 192.168.2.0 0.255.255.255 area 200
R2600A(config-router)#network 192.168.3.0 0.255.255.255 area 200
R2600A(config-router)#end
R2600A#show ip protocols(查看A 路由器OSPF协议的相关信息)
Routing Protocol is "ospf 100"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.3.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.0.0.0 0.255.255.255 area 200
Routing Information Sources:
Gateway Distance Last Update
Distance: (default is 110)
对路由器B进行类似配置:(查看B路由器OSPF协议的相关信息)
R2600B#show ip protocols
Routing Protocol is "ospf 100"
Outgoing update filter list for all interfaces is not set
Incoming update filter list for all interfaces is not set
Router ID 192.168.5.1
Number of areas in this router is 1. 1 normal 0 stub 0 nssa
Maximum path: 4
Routing for Networks:
192.168.3.0 0.0.0.255 area 200
192.168.4.0 0.0.0.255 area 200
192.168.5.0 0.0.0.255 area 200
Routing Information Sources:
Gateway Distance Last Update
192.168.3.1 110 00:01:26
Distance: (default is 110)
路由器A、B的路由表信息:
R2600A#show ip route(路由器A的路由表信息)
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, Ethernet0/0/0
C 192.168.2.0/24 is directly connected, Ethernet0/1/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
O 192.168.4.0/24 [110/11] via 192.168.3.2, 00:00:57, FastEthernet0/0
O 192.168.5.0/24 [110/11] via 192.168.3.2, 00:00:57, FastEthernet0/0
R2600A#
R2600B#show ip route(路由器B的路由表信息)
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
O 192.168.1.0/24 [110/11] via 192.168.3.1, 00:01:43, FastEthernet0/0
O 192.168.2.0/24 [110/11] via 192.168.3.1, 00:01:43, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/0
C 192.168.4.0/24 is directly connected, Ethernet0/0/0
C 192.168.5.0/24 is directly connected, Ethernet0/1/0
R2600B#
在PC1上测试连通性,结果如下:
五、 实验总结
通过本次试验学会了静/动态路由的配置方法,特别是对RIP协议及OSPF协议的配置方法,同时也让我对路由器内部工作原理有了更进一步的了解。查看路由器的路由表可以了解到现时的工作状态,根据实际的要求对路由器进行设置,在路由表可以及时的显示出来。在试验的过程中也提高了动手能力,为以后的路由器的相关操作打下基础。