zl程序教程

您现在的位置是:首页 >  工具

当前栏目

华为运营商级路由器配置示例 | IPv4浮动静态路由

配置静态路由华为 示例 路由器 运营商 浮动
2023-09-14 09:09:07 时间

组网需求

路由器各接口及主机的IP地址和掩码如图1所示。在DeviceA上配置两条去往10.1.5.0/24的IPv4静态路由,其中优先级较高的主静态路由经过DeviceB,浮动静态路由经过DeviceC。

图1 配置IPv4浮动静态路由组网图

配置思路

  1. 首先配置各路由器各接口的IPv4地址。
  2. 在DeviceB和DeviceC上配置到目的地址10.1.5.0/24的IPv4静态路由。
  3. 在DeviceA上配置去往10.1.3.0/24和10.1.4.0/24的IPv4静态路由。
  4. 在DeviceA上配置两条去往10.1.5.0/24的优先级不同的IPv4静态路由。
  5. 为了使各路由器能够互通,在DeviceD上配置去往10.1.1.0/24和10.1.2.0/24的IPv4静态路由。

操作步骤

1.配置各接口的IP地址请参见配置文件

2.配置IPv4静态路由

# 在DeviceB上配置IPv4静态路由。

[~DeviceB] ip route-static 10.1.5.0 24 10.1.3.2
[*DeviceB] commit

# 在DeviceC上配置IPv4静态路由。

[~DeviceC] ip route-static 10.1.5.0 24 10.1.4.2
[*DeviceC] commit

# 在DeviceA上配置IPv4静态路由。

[~DeviceA] ip route-static 10.1.3.0 24 10.1.1.2
[*DeviceA] ip route-static 10.1.4.0 24 10.1.2.2
[*DeviceA] ip route-static 10.1.5.0 24 10.1.1.2
[*DeviceA] ip route-static 10.1.5.0 24 10.1.2.2 preference 100
[*DeviceA] commit

# 在DeviceD上配置IPv4静态路由。

[~DeviceD] ip route-static 10.1.1.0 24 10.1.3.1
[*DeviceD] ip route-static 10.1.2.0 24 10.1.4.1
[*DeviceD] commit

3.查看配置结果

# 查看DeviceA上IP路由表中的静态路由信息。

<DeviceA> display ip routing-table protocol static
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
_public_ Routing Table : Static

         Destinations : 3        Routes : 3        Configured Routes : 3      
Static routing table status : <Active>
         Destinations : 3        Routes : 3         

Destination/Mask    Proto  Pre  Cost        Flags NextHop         Interface

       10.1.3.0/24  Static 60   0             RD 10.1.1.2        GigabitEthernet1/0/1
       10.1.4.0/24  Static 60   0             RD 10.1.2.2        GigabitEthernet1/0/2
    10.1.5.0/24  Static 60   0             RD 10.1.1.2        GigabitEthernet1/0/1

Static routing table status : <Inactive>
         Destinations : 0        Routes : 0

# 在DeviceA上使用tracert命令验证连通性。

<DeviceA> tracert 10.1.5.1
  traceroute to  10.1.5.1(10.1.5.1), max hops: 30 ,packet length: 40
 1 10.1.1.2 90 ms  1 ms  1 ms
 2 10.1.5.1 4 ms  1 ms  2 ms

# 在DeviceA的GE1/0/1接口下执行shutdown命令,模拟出现链路故障。

[~DeviceA] interface GigabitEthernet 1/0/1 
[~DeviceA-GigabitEthernet1/0/1] shutdown 
[~DeviceA-GigabitEthernet1/0/1] commit 

# 查看DeviceA上IP路由表中的静态路由信息,可以看到去往10.1.5.0/24的路由切换到了下一跳为10.1.2.2的浮动静态路由上。

[~DeviceA-GigabitEthernet1/0/1] quit
[~DeviceA] quit
<DeviceA> display ip routing-table protocol static
Route Flags: R - relay, D - download to fib, T - to vpn-instance, B - black hole route
------------------------------------------------------------------------------
_public_ Routing Table : Static

         Destinations : 2        Routes : 2        Configured Routes : 2      
Static routing table status : <Active>
         Destinations : 2        Routes : 2         

Destination/Mask    Proto  Pre  Cost        Flags NextHop         Interface

       10.1.4.0/24  Static 60   0             RD 10.1.2.2        GigabitEthernet1/0/2
    10.1.5.0/24  Static 100   0             RD 10.1.2.2        GigabitEthernet1/0/2

Static routing table status : <Inactive>
         Destinations : 0        Routes : 0

# 在DeviceA上使用tracert命令验证连通性。

<DeviceA> tracert 10.1.5.1
  traceroute to  10.1.5.1(10.1.5.1), max hops: 30 ,packet length: 40
 1 10.1.2.2 100 ms  1 ms  1 ms
 2 10.1.5.1 5 ms  1 ms  2 ms