静态路由实验

静态路由实验配置

首先绘制出本次实验需要的网路拓扑

image-20220928215804554

测试主机之间是否能相互通信

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,意思是该路由器的静态网络地址

网络拓扑简化图如下

192.168.1.0
192.168.2.0
192.168.3.0
192.168.1.101
Router0 Fa0/0 (192.168.1.1)
Router0 Fa0/1 (192.168.2.1)
Router1 Fa0/1 (192.168.2.2)
Router1 Fa0/0 (192.168.3.1)
192.168.3.101

1. 确定目的网络和下一跳地址

目的网络:路由器不能到达的网络地址就是目的网络

步骤:

  1. 观察网络拓扑,以其中一个路由器Router0开始分析

  2. 确定Router0所有不能到达的网络地址

    观察可得无法直连的网络地址有:192.168.3.0

  3. 确定Router1所有不能到达的网络地址

    观察可得无法直连的网络地址有:192.168.1.0

  4. 开始分析下一跳地址,以Router0为例

    例:要发送报文到 目的网络 192.168.1.0,故下一跳为主机Fa端口的网络地址 192.168.1.101

    目的网络地址下一跳地址
    192.168.1.0192.168.1.101
    192.168.2.0192.168.2.2
    192.168.3.0192.168.2.2

    不难理解,你的下一跳地址就是报文从当前路由器发出之后到达的第一个其他主机/路由器的端口的IP地址

  5. 开始分析下一跳地址,以Router1为例

    例:要发送报文到 目的网络 192.168.1.0 需要先经过Router0 端口Fa0/1 192.168.2.1

    故下一跳为Router0端口Fa0/1的网络地址

    目的网络地址下一跳地址
    192.168.1.0192.168.2.1
    192.168.2.0192.168.2.1
    192.168.3.0192.168.3.101

2. 配置静态路由表

前面我们分析了两个路由器的目的网络和下一跳地址,现在我们需要开始配置静态路由表

直连网络在上面已经有所体现,配置静态路由表的时候不需要配置直连网络

只需要配置路由器无法到达的网络地址即可

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

测试完毕,静态路由配置成功
在这里插入图片描述

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值