首先绘制出本次实验需要的网路拓扑
测试主机之间是否能相互通信
C:>ping 192.168.3.101
Pinging 192.168.3.101 with 32 bytes of data:
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
Reply from 192.168.1.1: Destination host unreachable.
Ping statistics for 192.168.3.101:
Packets: Sent = 4, Received = 0, Lost = 4 (100% loss),
显示目的网络不可达
查看当前Router0路由表
Router#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
查看当前Router1路由表
Router#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.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
其中;显示的C为Connected;意思是该路由器的直连网络地址
显示S为Static;意思是该路由器的静态网络地址
网络拓扑简化图如下
目的网络;路由器不能到达的网络地址就是目的网络
步骤;
观察网络拓扑;以其中一个路由器Router0开始分析
确定Router0所有不能到达的网络地址
观察可得无法直连的网络地址有;192.168.3.0
确定Router1所有不能到达的网络地址
观察可得无法直连的网络地址有;192.168.1.0
开始分析下一跳地址;以Router0为例
例;要发送报文到 目的网络 192.168.1.0;故下一跳为主机Fa端口的网络地址 192.168.1.101
不难理解;你的下一跳地址就是报文从当前路由器发出之后到达的第一个其他主机/路由器的端口的IP地址
开始分析下一跳地址;以Router1为例
例;要发送报文到 目的网络 192.168.1.0 需要先经过Router0 端口Fa0/1 192.168.2.1
故下一跳为Router0端口Fa0/1的网络地址
前面我们分析了两个路由器的目的网络和下一跳地址;现在我们需要开始配置静态路由表
直连网络在上面已经有所体现;配置静态路由表的时候不需要配置直连网络
只需要配置路由器无法到达的网络地址即可
Router0的配置前的路由表
C 192.168.1.0/24 is directly connected, FastEthernet0/0
C 192.168.2.0/24 is directly connected, FastEthernet0/1
Router1的配置前的路由表
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
配置静态路由表的命令
添加一个静态路由表Router(config)# ip route [目的网络] [子网掩码] [下一跳网络地址]
删除一个静态路由表Router(config)# no ip route [目的网络] [子网掩码] [下一跳网络地址]
添加路由表;Router0路由器命令行配置如下
Router>en
Router#conf
Router#configure te
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ip route 192.168.3.0 255.255.255.0 192.168.2.2
同理;Router1路由器也配置
Router>en
Router#conf
Router#configure ter
Router#configure terminal
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#ip route 192.168.1.0 255.255.255.0 192.168.2.1
查看路由表;
Router0配置后的路由表
Router#show ip route
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
Router1配置后的路由表
Router#show ip route
S 192.168.1.0/24 [1/0] via 192.168.2.1
C 192.168.2.0/24 is directly connected, FastEthernet0/0
C 192.168.3.0/24 is directly connected, FastEthernet0/1
测试主机之间是否能够相互通信
左边的主机ping右边的主机;测试成功
C:>ping 192.168.3.101
Pinging 192.168.3.101 with 32 bytes of data:
Reply from 192.168.3.101: bytes=32 time<1ms TTL=126
Reply from 192.168.3.101: bytes=32 time=1ms TTL=126
Reply from 192.168.3.101: bytes=32 time=1ms TTL=126
Reply from 192.168.3.101: bytes=32 time<1ms TTL=126
Ping statistics for 192.168.3.101:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 1ms, Average = 0ms
右边的主机ping左边的主机;测试成功
C:>ping 192.168.1.101
Pinging 192.168.1.101 with 32 bytes of data:
Reply from 192.168.1.101: bytes=32 time<1ms TTL=126
Reply from 192.168.1.101: bytes=32 time<1ms TTL=126
Reply from 192.168.1.101: bytes=32 time<1ms TTL=126
Reply from 192.168.1.101: bytes=32 time<1ms TTL=126
Ping statistics for 192.168.1.101:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
测试完毕;静态路由配置成功