第5章 直连与静态路由技术
5.1 实验一:直连路由
实验要求
构建如图5.1所示网络拓扑结构,网络设备的IP地址规划见表5.1。要求分析路由器
的直连路由。该实验在PacketTracer仿真环境下完成。
图5.1 直连路由网络拓扑结构
表5.1 IP地址规划
设 备端 口IP 地址子网掩码默认网关
R1 fa0/0 192.168.1.1 255.255.255.0 
fa0/1 192.168.2.1 255.255.255.0 
R2 fa0/0 192.168.3.1 255.255.255.0 
fa0/1 192.168.2.2 255.255.255.0 
PC1 网卡192.168.1.100 255.255.255.0 192.168.1.1 
PC2 网卡192.168.3.100 255.255.255.0 192.168.3.1 
实验过程
按照如表5.1所示IP地址的规划对如图5.1所示网络进行网络地址配置,配置完成后, 
通过“showiproute”命令可以查看路由器R1和路由器R2的路由表。
(1)配置路由器R1。 
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R1 //为路由器命名

第5 章 直连与静态路由技术
117 
R1(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0 
R1(config-if)#ip address 192.168.1.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
R1(config-if)#exit //退出
R1(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R1(config-if)#ip address 192.168.2.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
(2)配置路由器R2。 
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R2 //为路由器命名
R2(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0 
R2(config-if)#ip address 192.168.3.1 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
R2(config-if)#exit //退出
R2(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R2(config-if)#ip address 192.168.2.2 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
(3)查看路由器R1的路由表。
通过“showiproute”命令查看路由器R1的路由表如下。 
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, FastEthernet0/0 
C 192.168.2.0/24 is directly connected, FastEthernet0/1 
R1# 
(4)查看路由器R2的路由表。
通过“showiproute”命令查看路由器R2的路由表如下。 
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

网络互联技术实验教程(基于思科设备) 
118 
Gateway of last resort is not set 
C 192.168.2.0/24 is directly connected, FastEthernet0/1 
C 192.168.3.0/24 is directly connected, FastEthernet0/0 
R2# 
两台路由器的路由表中,以字母C表示的为直连路由,即connected。路由器R1和路
由器R2分别获得了两条直连路由。路由器R1获得了到网络192.168.1.0以及192.168.2.0 
的直连路由,其中,网络192.168.1.0与路由器R1的端口fa0/0相连,网络192.168.2.0与路
由器R1的端口fa0/1相连。
路由器R2获得了到网络192.168.2.0以及网络192.168.3.0的直连路由,其中,网络
192.168.2.0与路由器R2的端口fa0/1相连,网络192.168.3.0与路由器R2的端口fa0/0 
相连。
5.2 实验二:静态路由配置
实验要求
构建如图5.1所示网络拓扑结构,网络设备的IP地址规划见表5.1。要求通过配置静
态路由实现网络互联互通。该实验在PacketTracer仿真环境下完成。
实验过程
(1)按照表5.1网络地址规划对网络拓扑中的设备进行基本配置。
首先配置路由器R1。 
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R1 //为路由器命名
R1(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0 
R1(config-if)#ip address 192.168.1.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
R1(config-if)#exit //退出
R1(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R1(config-if)#ip address 192.168.2.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
其次配置路由器R2。 
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R2 //为路由器命名
R2(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0 
R2(config-if)#ip address 192.168.3.1 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
R2(config-if)#exit //退出
R2(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R2(config-if)#ip address 192.168.2.2 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活

第5 章 直连与静态路由技术
119 
最后配置计算机。
计算机PC1和计算机PC2地址配置如图5.2和图5.3所示。
图5.2 计算机PC1地址配置
图5.3 计算机PC2地址配置
(2)配置静态路由。
第一,在路由器R1中添加到网络192.168.3.0的静态路由,具体命令如下:R1(config) 
#iproute192.168.3.0255.255.255.0192.168.2.2。
通过“showiproute”命令查看路由器R1的路由表。 
R1#show ip route

网络互联技术实验教程(基于思科设备) 
120 
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 
S 192.168.3.0/24 [1/0]via 192.168.2.2 
R1# 
通过路由表可以看出,静态路由添加成功。
第二,在路由器R2中添加到网络192.168.1.0的静态路由,具体命令如下:R2(config) 
#iproute192.168.1.0255.255.255.0192.168.2.1。
通过“showiproute”命令查看路由器R2的路由表。 
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, FastEthernet0/1 
C 192.168.3.0/24 is directly connected, FastEthernet0/0 
R2# 
通过路由表可以看出,静态路由添加成功。
(3)通过ping命令测试主机PC1与主机PC2的网络连通性。 
PC>ping 192.168.3.100 
Pinging 192.168.3.100 with 32 bytes of data: 
Reply from 192.168.3.100: bytes=32 time=14ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=15ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=10ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=12ms TTL=126 
Ping statistics for 192.168.3.100: 
Packets: Sent =4, Received =4, Lost =0 (0%loss), 
Approximate round trip times in milli-seconds: 
Minimum =10ms, Maximum =15ms, Average =12ms 
PC>

第5 章 直连与静态路由技术
121 
实验结果表明,通过配置静态路由实现了网络互联互通。
5.3 实验三:浮动静态路由配置
实验要求
构建如图5.4所示网络拓扑结构,两台路由器之间通过两条链路相连,分别为以太网端
口fa0/1相连链路以及串口s0/0/0相连链路。IP地址规划见表5.2,要求通过在两台路由
器之间配置浮动静态路由从而实现网络冗余备份,增强网络的稳定性。该实验在Packet 
Tracer仿真环境下完成。
图5.4 实现浮动静态路由拓扑结构
表5.2 浮动静态路由IP地址规划
设 备端 口IP 地址子网掩码默认网关
R1 
fa0/0 192.168.1.1 255.255.255.0 
fa0/1 192.168.2.1 255.255.255.0 
s0/0/0 192.168.4.1 255.255.255.0 
R2 
fa0/0 192.168.3.1 255.255.255.0 
fa0/1 192.168.2.2 255.255.255.0 
s0/0/0 192.168.4.2 255.255.255.0 
PC1 网卡192.168.1.100 255.255.255.0 192.168.1.1 
PC2 网卡192.168.3.100 255.255.255.0 192.168.3.1 
实验过程
在构建网络拓扑时,由于思科2811路由器默认不带串口模块,因此需要插入该模块。
在CiscoPacketTracer仿真软件中,插入串口模块的操作过程见第1章实验一。
(1)对路由器R1进行基本配置。 
Router> //用户模式
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R1 //为路由器命名
R1(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0

网络互联技术实验教程(基于思科设备) 
122 
R1(config-if)#ip address 192.168.1.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
R1(config-if)#exit //退出
R1(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R1(config-if)#ip address 192.168.2.1 255.255.255.0 //配置IP 地址
R1(config-if)#no shu //激活
R1(config-if)#exit //退出
R1(config)#interface serial 0/0/0 //进入路由器端口s0/0/0 
R1(config-if)#ip address 192.168.4.1 255.255.255.0 //配置IP 地址
R1(config-if)#clock rate 64000 //配置时钟频率
R1(config-if)#exit //退出
R1(config)# 
(2)对路由器R2进行基本配置。 
Router>en //进入特权模式
Router#config t //进入全局配置模式
Router(config)#hostname R2 //为路由器命名
R2(config)#interface fastEthernet 0/0 //进入路由器端口fa0/0 
R2(config-if)#ip address 192.168.3.1 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
R2(config-if)#exit //退出
R2(config)#interface fastEthernet 0/1 //进入路由器端口fa0/1 
R2(config-if)#ip address 192.168.2.2 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
R2(config-if)#exit //退出
R2(config)#interface serial 0/0/0 //进入路由器端口s0/0/0 
R2(config-if)#ip address 192.168.4.2 255.255.255.0 //配置IP 地址
R2(config-if)#no shu //激活
R2(config-if)#exit //退出
Router(config)# 
(3)按照表5.2中的规划,配置计算机PC1和计算机PC2的网络参数。
(4)配置浮动静态路由。
第一,在路由器R1上配置静态路由以及浮动静态路由。 
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2 
R1(config)#ip route 192.168.3.0 255.255.255.0 192.168.4.2 2 
第二,在路由器R2上配置静态路由以及浮动静态路由。 
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1 
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.4.1 2 
(5)在路由器R1上通过“showiproute”命令查看路由表。 
R1#show ip route 
Codes: C -connected, S -static, I -IGRP, R -RIP, M -mobile, B -BGP

第5 章 直连与静态路由技术
123 
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 
S 192.168.3.0/24 [1/0]via 192.168.2.2 
C 192.168.4.0/24 is directly connected, Serial0/0/0 
R1# 
结果表明,路由器R1 通过下一跳地址为192.168.2.2 的静态路由到达目标网络
192.168.3.0,而路由配置中通过下一跳地址为192.168.4.2到达同样的目标网络192.168.3.0 
的静态路由条目并没有出现在路由表中。
(6)在路由器R2上通过“showiproute”命令查看路由表。 
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, FastEthernet0/1 
C 192.168.3.0/24 is directly connected, FastEthernet0/0 
C 192.168.4.0/24 is directly connected, Serial0/0/0 
R2# 
结果表明,路由器R2到达网络192.168.1.0的下一跳地址为192.168.2.1。能够到达同
一网络192.168.1.0的下一跳为192.168.4.1的静态路由并没有出现在路由器R2的路由
表中。
(7)通过ping命令测试两台主机的连通性,结果如下。 
PC>ping 192.168.3.100 
Pinging 192.168.3.100 with 32 bytes of data: 
Reply from 192.168.3.100: bytes=32 time=54ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=12ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=9ms TTL=126 
Reply from 192.168.3.100: bytes=32 time=93ms TTL=126 
Ping statistics for 192.168.3.100: 
Packets: Sent =4, Received =4, Lost =0 (0%loss),

网络互联技术实验教程(基于思科设备) 
124 
Approximate round trip times in milli-seconds: 
Minimum =9ms, Maximum =93ms, Average =42ms 
PC> 
实验结果表明,两台主机是连通的。通过路由跟踪命令tracert可以看出,从主机PC1 
到主机PC2经过的路由如下。 
PC>tracert 192.168.3.100 
Tracing route to 192.168.3.100 over a maximum of 30 hops: 
1 31 ms 31 ms 32 ms 192.168.1.1 
2 19 ms 63 ms 63 ms 192.168.2.2 
3 94 ms 94 ms 94 ms 192.168.3.100 
Trace complete. 
PC> 
实验结果表明,数据包从路由器R1通过下一跳地址192.168.2.2 转发到目标网络
192.168.3.0。
接下来验证两台路由器之间的端口fa0/1链路出现故障后的网络连通情况。
(1)进入路由器R1,将路由器R1的端口fa0/1停掉,操作如下。 
R1(config)#interface fastEthernet 0/1 
R1(config-if)#shutdown 
(2)在路由器R1上执行查看路由表命令“showiproute”,结果如下。 
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, FastEthernet0/0 
S 192.168.3.0/24 [2/0]via 192.168.4.2 
C 192.168.4.0/24 is directly connected, Serial0/0/0 
R1# 
结果表明,路由器R1通过下一跳地址192.168.4.2到达目标网络192.168.3.0,此时的
管理距离和度量值表示为[2/0]。也就是说,管理距离值为2,不再是默认的1了。
(3)通过“showiproute”命令查看路由器R2的路由表,结果如下。 
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

第5 章 直连与静态路由技术
125 
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 [2/0]via 192.168.4.1 
C 192.168.3.0/24 is directly connected, FastEthernet0/0 
C 192.168.4.0/24 is directly connected, Serial0/0/0 
R2# 
结果表明,路由器R2到网络192.168.1.0的路由条目发生了改变,下一跳地址由之前
的192.168.2.1变成了现在的192.168.4.1。管理距离由1变成了现在的2。
(4)通过tracert命令跟踪主机PC1到主机PC2的路由信息,结果如下。 
PC>tracert 192.168.3.100 
Tracing route to 192.168.3.100 over a maximum of 30 hops: 
1 31 ms 5 ms 31 ms 192.168.1.1 
2 62 ms 62 ms 63 ms 192.168.4.2 
3 94 ms 28 ms 94 ms 192.168.3.100 
Trace complete. 
PC> 
结果表明,具有冗余链路的浮动静态路由发挥了作用,确保了网络的连通性。
5.4 实验四:默认路由配置
实验要求
设置如图5.5所示的网络中,3台路由器连接4个网络,整个网络的IP地址规划见表5.3。
路由器Router0和路由器Router2为两个末梢网络的路由,实验要求使用默认路由使网络
互联互通。该实验在PacketTracer仿真环境下完成。
图5.5 3台路由器连接4个网络情况
表5.3 IP地址规划
设 备端 口IP地址子网掩码默认网关
R0 fa0/0 192.168.1.1 255.255.255.0 
fa0/1 192.168.2.1 255.255.255.0