浮动静态路由
本人第一次写博,只为技术交流,希望大家多提意见。
拓扑图如上:首先配置路由IP地址
R1:
en (进入特权模式)
conf t (进入全局模式)
int f0/0 (进入接口f0/0)
ip add 192.168.12.1 255.255.255.0 (配置f0/0接口地址)
no sh (启用接口)
int f0/1 (进入f0/1)
ip add 192.168.21.1 255.255.255.0 (配置f0/1接口IP地址)
no sh (启用接口)
int e0/0/0 (进入e0/0/0接口)
ip add 10.10.10.1 255.255.255.0 (配置e0/0/0IP地址)
no sh (启用接口)
ex (退出接口配置模式)
ip route 20.20.20.0 255.255.255.0 192.168.21.2 130 (配置静态路由 目的20.20.20.0网段 掩码255.255.255.0 下一条地址192.168.21.2 管理距离为130 默认静态路由管理地址为1 RIP管理地址为120 管理距离越小优先级越高)
router rip (启动RIP路由协议)
ver 2 (版本2)
no auto-summary (关闭自动汇总)
network 192.168.12.0 (通告192.168.12.0 网段)
network 10.10.10.0 (通告10.10.10.0网段)
R2配置
en
conf t
int f0/0
ip add 192.168.12.2 255.255.255.0
no sh
int f0/1
ip add 192.168.21.2 255.255.255.0
no sh
int e0/0/0
ip add 20.20.20.1 255.255.255.0
no sh
ex
ip route 10.10.10.0 255.255.255.0 192.168.21.1 130 (静态路由 管理距离为130)
router rip
version 2
no auto-summary
network 20.20.20.0
network 192.168.12.0
配置好路由之后给PC机配置IP地址
PC1 PC2
IP:10.10.10.2 IP:20.20.20.2
掩码:255.255.255.0 掩码:255.255.255.0
网关:10.10.10.1 网关:20.20.20.1
设置好PC机后用PC1 ping PC2
会发现R1和R2 f0/0 的接口闪个不停。说明数据走的是此路线
然后查看R1路由表:
特权模式下:show ip route
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Ethernet0/0/0
20.0.0.0/24 is subnetted, 1 subnets
R 20.20.20.0 [120/1] via 192.168.12.2, 00:00:07, FastEthernet0/0
C 192.168.12.0/24 is directly connected, FastEthernet0/0
C 192.168.21.0/24 is directly connected, FastEthernet0/1
R2的路由表
10.0.0.0/24 is subnetted, 1 subnets
R 10.10.10.0 [120/1] via 192.168.12.1, 00:00:14, FastEthernet0/0
20.0.0.0/24 is subnetted, 1 subnets
C 20.20.20.0 is directly connected, Ethernet0/0/0
C 192.168.12.0/24 is directly connected, FastEthernet0/0
C 192.168.21.0/24 is directly connected, FastEthernet0/1
发现2个路由表里面启动的都是RIP路由协议,没有静态路由。这是因为我们将静态路由的管理距离值设为130。在RIP管理距离值120的后面。所以将静态路由作为备份路由来使用。
若如下设置时:
R1
en
conf t
int f0/0
shutdown
关闭2边路由的F0/0接口时 我们在用PC1 ping PC2 会发现两边的F0/1接口会不停地闪,表明数据通过此接口传输。
然后show ip router
R1
10.0.0.0/24 is subnetted, 1 subnets
C 10.10.10.0 is directly connected, Ethernet0/0/0
20.0.0.0/24 is subnetted, 1 subnets
S 20.20.20.0 [130/0] via 192.168.21.2
C 192.168.21.0/24 is directly connected, FastEthernet0/1
R2
10.0.0.0/24 is subnetted, 1 subnets
S 10.10.10.0 [130/0] via 192.168.21.1
20.0.0.0/24 is subnetted, 1 subnets
C 20.20.20.0 is directly connected, Ethernet0/0/0
C 192.168.21.0/24 is directly connected, FastEthernet0/1
发现此时使用的是静态路由协议。当接口F0/0断掉的时候,会启用备用的静态路由。因此我们使用RIP协议的时候可以用浮动静态路由作为备份,当然你得将静态路由管理距离值设为大于120。
转载于:https://blog.51cto.com/3427046/794057