静态路由和 RIP 配置实验
参考资料
- 计算机网络实验教程
注意
- 在 Packet Tracer 中选择
PT-Router
- 用
串行 DTE
连接两个路由器的Serial
接口 - PC 和路由器选择铜交叉线
- 真机实验时,关闭防火墙,设置连接为家庭网络
- 用
拓扑图
配置 Router 1
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no # 选择no
Press RETURN to get started!
r1>enable # 进入admin模式
r1#
r1#configure terminal # 进入管理终端
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#interface FastEthernet1/0 # 进入端口1/0
r1(config-if)#ip address 192.168.1.1 255.255.255.0 # 配置端口的ip地址
r1(config-if)#no shutdown # 开启此端口,使它转发数据
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r1(config-if)#exit # 退出
r1(config)#interface serial 2/0 # 进入S2/0端口模式
r1(config-if)#no shutdown # 开启此端口
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
r1(config-if)#ip address 192.168.2.1 255.255.255.0 # 配置此端口的ip地址
r1(config-if)#clock rate 9600 # 配置此端口的时钟速率
r1(config-if)#exit # 退出
r1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2 # 配置静态路由
配置 Router 2
--- System Configuration Dialog ---
Would you like to enter the initial configuration dialog? [yes/no]: no # 选择no
Press RETURN to get started!
r1>enable # 进入admin模式
r1#
r1#configure terminal # 进入管理终端
Enter configuration commands, one per line. End with CNTL/Z.
r1(config)#interface FastEthernet1/0 # 进入端口1/0
r1(config-if)#ip address 192.168.3.1 255.255.255.0 # 配置端口的ip地址
r1(config-if)#no shutdown # 开启此端口,使它转发数据
%LINK-5-CHANGED: Interface FastEthernet1/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet1/0, changed state to up
r1(config-if)#exit # 退出
r1(config)#interface serial 2/0 # 进入S2/0端口模式
r1(config-if)#no shutdown # 开启此端口
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
r1(config-if)#ip address 192.168.2.2 255.255.255.0 # 配置此端口的ip地址
r1(config-if)#exit # 退出
r1(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1 # 配置静态路由
配置 PC1
- IPv4地址:192.168.1.11
- 子网掩码:255.255.255.0
- 默认网关:192.168.1.1
配置 PC2
- IPv4地址:192.168.3.22
- 子网掩码:255.255.255.0
- 默认网关:192.168.3.1
完成后的路由表
Router 1
r1#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, FastEthernet1/0
C 192.168.2.0/24 is directly connected, Serial2/0
S 192.168.3.0/24 [1/0] via 192.168.2.2
Router 2
r2#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.2.1
C 192.168.2.0/24 is directly connected, Serial2/0
C 192.168.3.0/24 is directly connected, FastEthernet1/0
测试命令
- 查看静态路由配置
r1#show ip route
- 验证路由器接口配置
r1#show ip interface brief
# 在此实验中,配置应如下
# FastEthernet1/0和Serial2/0的Status应为up,router2同理.
r1#show ip interface brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet1/0 192.168.1.1 YES manual up up
Serial2/0 192.168.2.1 YES manual up up
Serial3/0 unassigned YES unset administratively down down
FastEthernet4/0 unassigned YES unset administratively down down
FastEthernet5/0 unassigned YES unset administratively down down
配置 RIP
RIP 的配置可在静态路由的基础上进行
- 删除 Router1,Router2中的静态路由
r1(config)#no ip route 192.168.3.0 255.255.255.0 192.168.2.2 #删除Router1的转发表
r2(config)#no ip route 192.168.1.0 255.255.255.0 192.168.2.1 #删除Router2的转发表
- 分别对 Router1,Router2 设置 RIP
r1(config)#router rip #进入RIP配置模式
r1(config-router)#version 2 #设置版本号
r1(config-router)#network 192.168.1.0 #声明Router1连接的两个网络的网络号
r1(config-router)#network 192.168.2.0
r2(config)#router rip #进入RIP配置模式
r2(config-router)#version 2 #设置版本号
r2(config-router)#network 192.168.3.0 #声明Router2连接的两个网络的网络号
r2(config-router)#network 192.168.2.0