2.3 浮动静态路由
 
实验连接图
提要描述
   浮动静态路由与其他的静态路由不同,在路由表中其他静态路由总是优先于浮动静态路由,仅在首选静态路由失败的时候,浮动静态路由才会出现在路由表中。因此缺省情况下,对于到相同的目标网络,其他静态路由总是优先于浮动静态路由。
实验目标: 主链路(一般静态路由) Down ,备份链路(浮动静态路由)生效,主链路恢复正常,备份链路失效(在预备状态)。
基本配置
R1 的配置
R2 的配置
!
hostname R1
!
interface Loopback0
 ip address 4.4.4.4 255.255.255.0
!
interface Serial1/0
 ip address 12.1.1.1 255.255.255.0
 no sh
 clock rate 64000
!
interface Serial1/1
 ip address 21.1.1.1 255.255.255.0
no sh
!
!
interface Loopback0
 ip address 1.1.1.1 255.255.255.0
!
interface Loopback1
 ip address 2.2.2.2 255.255.255.0
!
interface Loopback2
 ip address 3.3.3.3 255.255.255.0
!
interface Serial1/0
 ip address 12.1.1.2 255.255.255.0
no sh
!
interface Serial1/1
 ip address 21.1.1.2 255.255.255.0
no sh
!
↓调试配置及监测步骤↓
 
R1 建立浮动静态路由:
ip route 1.1.1.0 255.255.255.0 12.1.1.2
ip route 1.1.1.0 255.255.255.0 21.1.1.2 50
ip route 2.2.2.0 255.255.255.0 12.1.1.2
ip route 2.2.2.0 255.255.255.0 21.1.1.2 50
ip route 3.3.3.0 255.255.255.0 12.1.1.2
ip route 3.3.3.0 255.255.255.0 21.1.1.2 50
R2 建立浮动静态路由
ip route 4.4.4.0 255.255.255.0 12.1.1.1
ip route 4.4.4.0 255.255.255.0 21.1.1.1 50
注意: 蓝色 的路由形式就是浮动静态路由路由,路由后面的权值 50 表示指定的(管理距离), 管理距离越高其路由优先权越低(权值范围在 1-255 之间),例如:指向下一跳地址 IPv4 的静态路由的管理距离为 1 ,而指向出站接口的静态路由的管理距离为 0 。如果有两条静态路由指向相同的目标网络,一条指向下一跳地址,一条指向出站接口,那么则优选后者(管理距离越低路由优先权越高)。
 
下面看看 R1 三种情况的路由表: 1 :正常情况 --- à 2 :主链路失效 --- à 3 :主链路恢复
 
正常情况
R1#show ip route
     1.0.0.0/24 is subnetted, 1 subnets
S       1.1.1.0 [1/0] via 12.1.1.2
     2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [1/0] via 12.1.1.2
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 12.1.1.2
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     21.0.0.0/24 is subnetted, 1 subnets
C       21.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
主链路失效
R1(config)#int s1/0
R1(config-if)#shutdown
*Jan  6 18:00:52.819: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to down
R1#sh ip route
     1.0.0.0/24 is subnetted, 1 subnets
S       1.1.1.0 [50/0] via 21.1.1.2
     2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [50/0] via 21.1.1.2
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [50/0] via 21.1.1.2
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     21.0.0.0/24 is subnetted, 1 subnets
C       21.1.1.0 is directly connected, Serial1/1
主链路恢复
R1(config)#int s1/0
R1(config-if)#no shutdown
*Jan  6 18:01:21.935: %LINK-3-UPDOWN: Interface Serial1/0, changed state to up
*Jan  6 18:01:22.935: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial1/0, changed state to up
R1#sh ip route
     1.0.0.0/24 is subnetted, 1 subnets
S       1.1.1.0 [1/0] via 12.1.1.2
     2.0.0.0/24 is subnetted, 1 subnets
S       2.2.2.0 [1/0] via 12.1.1.2
     3.0.0.0/24 is subnetted, 1 subnets
S       3.3.3.0 [1/0] via 12.1.1.2
     4.0.0.0/24 is subnetted, 1 subnets
C       4.4.4.0 is directly connected, Loopback0
     21.0.0.0/24 is subnetted, 1 subnets
C       21.1.1.0 is directly connected, Serial1/1
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, Serial1/0
 
通过以上对 R1 S1/0 接口的关开,可以看到 3 个路由表的变化(主备 / 链路的切换)。
 
提示: 在每条路由条目中的括号内的数字是,例如 [1/0] 前者指定了管理距离为 1 ,后者指定度量值为 0 (因为静态路由没有度量值)。 因此对于相同的目标网络,缺省情况下,到相同目标网络的静态路由总是优先于动态路由。