1. 实验目的
- 浮动静态路由的使用场景
- 浮动静态路由的配置
2. 实验拓扑
3. 实验步骤
(1)网络连通性
R1的配置
[Huawei]sysname R1
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]ip address 12.1.1.1 24
[R1-GigabitEthernet0/0/0]undo shutdown
[R1-GigabitEthernet0/0/0]quit
[R1]interface g0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.1.1.1 24
[R1-GigabitEthernet0/0/1]undo shutdown
[R1-GigabitEthernet0/0/1]quit
R2的配置
<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
[Huawei]sysname R2
[R2]interface g0/0/0
[R2-GigabitEthernet0/0/0]ip address 12.1.1.2 24
[R2-GigabitEthernet0/0/0]undo shutdown
[R2-GigabitEthernet0/0/0]quit
[R2]interface g0/0/1
[R2-GigabitEthernet0/0/1]ip address 10.1.1.2 24
[R2-GigabitEthernet0/0/1]undo shutdown
[R2-GigabitEthernet0/0/1]quit
[R2]interface LoopBack 0 //创建环回口编号为0
[R2-LoopBack0]ip address 8.8.8.8 32 //配置IP地址
[R2-LoopBack0]quit
【技术要点】
Loopback是路由器里面的一个逻辑接口。逻辑接口是指能够实现数据交换功能,但是物理上不存在、需要通过配置建立的接口。Loopback接口一旦被创建,其 物理状态和链路协议状态永远是Up,即使该接口上没有配置IP地址。正是因为这个特性,Loopback 接口具有特殊的用途。在本实验中loopback中的8.8.8.8相当于是公网上的一台服务器。
(2)浮动静态路由
如果实验需求:R1访问8.8.8.8的数据都从g0/0/0口出去,只有当g0/0/0的链路出了问题才会从g0/0/1口出去,我们就可以通过浮动静态路由来配置,其配置如下:
[R1]ip route-static 8.8.8.8 255.255.255.255 12.1.1.2 preference 50 //
[R1]ip route-static 8.8.8.8 255.255.255.255 10.1.1.2 preference 100
【技术要点】
Preference代表一条路由的可信任的程度,越小越优。
4. 实验调试
(1)查看R1的路由表
<R1>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.8.8.8/32 Static 50 0 RD 12.1.1.2 GigabitEthernet0/0/0
通过以上输出,我们可以看到路由表里面只有一条去往8.8.8.8的静态路由。
(2)查看8.8.8.8这条路由的详细信息
<R1>display ip routing-table 8.8.8.8 verbose
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Table : Public
Summary Count : 2
Destination: 8.8.8.8/32
Protocol: Static Process ID: 0
Preference: 50 Cost: 0
NextHop: 12.1.1.2 Neighbour: 0.0.0.0
State: Active Adv Relied Age: 00h12m54s
Tag: 0 Priority: medium
Label: NULL QoSInfo: 0x0
IndirectID: 0x80000001
RelayNextHop: 0.0.0.0 Interface: GigabitEthernet0/0/0
TunnelID: 0x0 Flags: RD
Destination: 8.8.8.8/32
Protocol: Static Process ID: 0
Preference: 100 Cost: 0
NextHop: 10.1.1.2 Neighbour: 0.0.0.0
State: Inactive Adv Relied Age: 00h12m41s
Tag: 0 Priority: medium
Label: NULL QoSInfo: 0x0
IndirectID: 0x80000002
RelayNextHop: 0.0.0.0 Interface: GigabitEthernet0/0/1
TunnelID: 0x0 Flags: R
通过以上输出,可以看到有两条路由,下一跳为12.1.1.2的路由优先级为50,下一跳为10.1.1.2的路由优先为100,优先级为50的路由被放到了路由表,优先级为100的没有被选中。
(3)关闭g0/0/0接口,造成g0/0/0口链路故障
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]shutdown
[R1-GigabitEthernet0/0/0]quit
(4)查看R1的路由表
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 5 Routes : 5
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.8.8.8/32 Static 100 0 RD 10.1.1.2 GigabitEthernet0/0/1
通过以上输出,可以看到优先级为100的路由出现在路由表中了,这就是浮动静态路由
(5)把R1的g0/0/0接口打开
[R1]interface g0/0/0
[R1-GigabitEthernet0/0/0]undo shutdown
[R1-GigabitEthernet0/0/0]quit
(6)查看R1的路由表
[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 7 Routes : 7
Destination/Mask Proto Pre Cost Flags NextHop Interface
8.8.8.8/32 Static 50 0 RD 12.1.1.2 GigabitEthernet0/0/0
通过以上输出可以看到优先级为50的路由又回到了路由表。
更多实验拓扑资料,可领取
实验拓扑(部分示意)
关注+点赞后,私信找我领取!