-
静态路由是指用户或网络管理员手工配置的路由信息。当网络的拓扑结构或链路状态发生改变时,需要网络管理人员手工修改静态路由信息。相比于动态路由协议,静态路由无需频繁地交换各自的路由表,配置简单。比较适合小型,简单的网络环境。
-
-
首先配置IP
端口配置IP地址部分略 命令=ip add “ip地址” “子网掩码”
IP 地址的主机位为其设备编号如R1 S0/0/0 端口在192.168.12.0网段,则该端口IP为192.168.12.1.以此类推.
这里我将R2的 E 0/0/0 口配置为192.168.20.2 /24.故PC2的网关地址为192.168.20.3/24.
这里将R1的 E 0/0/0 口配置为192.168.10.1/24.故PC1的网关地址为192.168.10.1/24.
实验步骤
[R1][R1]ip route-static 192.168.20.0 24 10.0.12.2
在R1上配置目的网段为PC-2所在网段的静态路由,地址为
192.168.20.0 子网掩码为255.255.255.0,数据发送到PC-2
需要先发送给R2,所以R2为R1的下一跳路由器,之间的直连链路
上的物理接口的IP地址即为下一跳IP地址,为10.0.12.2.
<R1>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 8 Routes : 8
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.12.0/24 Direct 0 0 D 10.0.12.1 Serial0/0/0
10.0.12.1/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
10.0.12.2/32 Direct 0 0 D 10.0.12.2 Serial0/0/0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.10.0/24 Direct 0 0 D 192.168.10.1 Ethernet0/0/0
192.168.10.1/32 Direct 0 0 D 127.0.0.1 Ethernet0/0/0
192.168.20.0/24 Static 60 0 RD 10.0.12.2 Serial0/0/0
**(就在上面,我头顶)可以看到R1上有PC-2所在网段的路由信息.**
[R2]ip route-static 192.168.20.0 24 10.0.23.3
**R2上做同样的配置,下一跳为R3的10.0.23.3.**
[R2]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 9 Routes : 9
Destination/Mask Proto Pre Cost Flags NextHop Interface
10.0.12.0/24 Direct 0 0 D 10.0.12.2 Serial0/0/0
10.0.12.1/32 Direct 0 0 D 10.0.12.1 Serial0/0/0
10.0.12.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/0
10.0.23.0/24 Direct 0 0 D 10.0.23.2 Serial0/0/1
10.0.23.2/32 Direct 0 0 D 127.0.0.1 Serial0/0/1
10.0.23.3/32 Direct 0 0 D 10.0.23.3 Serial0/0/1
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
192.168.20.0/24 Static 60 0 RD 10.0.23.3 Serial0/0/1
**这里再查看一下,确定有PC-2所在的网段路由信息.**
PC>ping 192.168.20.20
Ping 192.168.20.20: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!
--- 192.168.20.20 ping statistics ---
5 packet(s) transmitted
0 packet(s) received
100.00% packet loss
**这里用PC-1pingPC-2 发现无法建立连接,因为现在的配置
只是PC-1能够发送给PC-2数据,但是PC-2无法传送给PC-1.**
[R3]ip route-static 192.168.10.0 24 10.0.23.2
**在R3上配置去往PC-1网段的静态路由.**
[R2]ip route-static 192.168.10.0 24 10.0.12.1
**在R2上配置去往PC-1网段的静态路由.**
PC>ping 192.168.20.20
Ping 192.168.20.20: 32 data bytes, Press Ctrl_C to break
From 192.168.20.20: bytes=32 seq=1 ttl=125 time=94 ms
From 192.168.20.20: bytes=32 seq=2 ttl=125 time=125 ms
From 192.168.20.20: bytes=32 seq=3 ttl=125 time=125 ms
From 192.168.20.20: bytes=32 seq=4 ttl=125 time=109 ms
From 192.168.20.20: bytes=32 seq=5 ttl=125 time=125 ms
--- 192.168.20.20 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 94/115/125 ms
**最后成功ping通**