配置本地策略路由示例—详解版

简介: 本文介绍了一种基于报文长度的策略路由配置方案,实现RouterA与RouterB间不同长度报文通过不同下一跳地址转发。具体规则为:64-1400字节强制下一跳为192.168.1.2,1401-1500字节强制下一跳为192.168.2.2,其他长度按目的地址路由。实验中通过ping命令测试多种报文长度,并对比RouterB接口统计信息验证配置效果。结果表明,策略路由优先级高于常规路由,超MTU报文会触发分片导致统计翻倍,未匹配策略时由静态路由实现负载均衡。此方案展示了策略路由在流量工程中的灵活应用。

组网需求

RouterA与RouterB间有两条链路相连。

用户希望实现本机下发的不同长度的报文通过不同的下一跳地址进行转发,其中:

  1. 长度为64~1400字节的报文设置192.168.1.2作为下一跳地址。
  2. 长度为1401~1500字节的报文设置192.168.2.2作为下一跳地址。
  3. 所有其它长度的报文都按基于目的地址的方法进行路由选路。
  • 策略路由与路由策略(Routing Policy)存在以下不同:
  • 策略路由的操作对象是数据包,在路由表已经产生的情况下,不按照路由表进行转发,而是根据需要,依照某种策略改变数据包转发路径。
  • 路由策略的操作对象是路由信息。路由策略主要实现了路由过滤和路由属性设置等功能,它通过改变路由属性(包括可达性)来改变网络流量所经过的路径。

配置思路

采用如下思路配置本地策略路由:

  1. 在RouterA上配置IP报文长度匹配条件,以实现本机下发的不同长度的报文匹配不同的策略点。
  2. 在RouterA上配置本地策略路由的动作,以实现本机下发的不同长度的报文通过不同的下一跳地址进行转发。
  3. 使能本地策略路由。

操作步骤

配置IP

RouterA

#进入系统视图
<Huawei>system-view
#修改设备名称
[Huawei]sysname RouterA
#进入接口GE0/0/0视图
[RouterA]interface GigabitEthernet0/0/0
[RouterA-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[RouterA-GigabitEthernet0/0/0]quit
[RouterA]interface GigabitEthernet0/0/1
[RouterA-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[RouterA-GigabitEthernet0/0/1]quit
[RouterA]interface LoopBack0
[RouterA-LoopBack0]ip address 10.1.1.1 255.255.255.0
[RouterA-LoopBack0]quit

RouterB

<Huawei>system-view
[Huawei]sysname RouterB
[RouterB]interface GigabitEthernet0/0/0
[RouterB-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[RouterB-GigabitEthernet0/0/0]quit
[RouterB]interface GigabitEthernet0/0/1
[RouterB-GigabitEthernet0/0/1]ip address 192.168.2.2 24
[RouterB-GigabitEthernet0/0/1]quit
[RouterB]interface LoopBack0
[RouterB-LoopBack0]ip address 10.1.2.1 24
[RouterB-LoopBack0]quit

配置静态路由

RouterA

#配置静态路由,保证两条路径都可达,并且下一跳为对端接口地址
[RouterA]ip route-static 10.1.2.0 24 192.168.1.2
[RouterA]ip route-static 10.1.2.0 24 192.168.2.2

RouterB

[RouterB]ip route-static 10.1.1.0 24 192.168.1.1
[RouterB]ip route-static 10.1.1.0 24 192.168.2.1

配置策略路由

配置名称为policy-route的策略路由

#创建策略路由policy-route和策略点10,策略点10的模式为permit
[RouterA]policy-based-route policy-route permit node 10
#设置报文长度在64字节~1400字节之间的IP报文被匹配
[RouterA-policy-based-route-policy-route-10]if-match packet-length 64 1400
#配置本地策略路由中报文转发的下一跳为192.168.1.2
[RouterA-policy-based-route-policy-route-10]apply ip-address next-hop 192.168.1.2
[RouterA-policy-based-route-policy-route-10]quit
[RouterA]policy-based-route policy-route permit node 20
[RouterA-policy-based-route-policy-route-20]if-match packet-length 1401 1500
[RouterA-policy-based-route-policy-route-20]apply ip-address next-hop 192.168.2.2
[RouterA-policy-based-route-policy-route-20]quit

使能本地策略路由

#使能本地策略路由,策略名称为policy-route
[RouterA]ip local policy-based-route policy-route

验证配置结果

针对长度在64至1400字节范围内的报文,验证其下一跳路由配置的正确性

清空RouterB接口统计信息

#清除接口gigabitethernet0/0/0的统计信息
<RouterB>reset counters interface gigabitethernet 0/0/0
<RouterB>reset counters interface gigabitethernet 0/0/1

查看RouterB接口统计信息

#查看二层以太接口GigabitEthernet0/0/0的运行状态、接口基本配置和发送接收报文的统计信息
<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:08:19-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 96 bits/sec,Record time: 2025-06-16 21:04:49
Output peak rate 96 bits/sec,Record time: 2025-06-16 21:06:29
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:08:48-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 96 bits/sec,Record time: 2025-06-16 21:04:49
Output peak rate 96 bits/sec,Record time: 2025-06-16 21:06:29
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

在RouterA上Ping RouterB的Loopback0,并将报文数据字段长度设为80字节

<RouterA>ping -s 80 10.1.2.1
  PING 10.1.2.1: 80  data bytes, press CTRL_C to break
    Reply from 10.1.2.1: bytes=80 Sequence=1 ttl=255 time=240 ms
    Reply from 10.1.2.1: bytes=80 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=80 Sequence=3 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=80 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=80 Sequence=5 ttl=255 time=40 ms
  --- 10.1.2.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 20/70/240 ms

再次查看RouterB接口统计信息

<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:15:07-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 16 bits/sec, 0 packets/sec
Last 300 seconds output rate 16 bits/sec, 0 packets/sec
Input peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Output peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Input:  6 packets, 670 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                1,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  6 packets, 670 bytes
  Unicast:                  6,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:15:35-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 96 bits/sec,Record time: 2025-06-16 21:04:49
Output peak rate 96 bits/sec,Record time: 2025-06-16 21:06:29
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

比较执行命令ping -s 80 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet0/0/0发送报文总数量增加了6(其中一个是ARP应答报文),即RouterB接口GigabitEthernet0/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.1.2抓包效果如下图所示

针对长度在1401至1500字节范围内的报文,验证其下一跳路由配置的正确性

清空RouterB接口统计信息

<RouterB>reset counters interface gigabitethernet 0/0/0
<RouterB>reset counters interface gigabitethernet 0/0/1

查看RouterB接口统计信息

<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:22:05-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Output peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:22:22-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 96 bits/sec,Record time: 2025-06-16 21:04:49
Output peak rate 96 bits/sec,Record time: 2025-06-16 21:06:29
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

在RouterA上Ping RouterB的Loopback0,并将报文数据字段长度设为1401字节

<RouterA>ping -s 1401 10.1.2.1
  PING 10.1.2.1: 1401  data bytes, press CTRL_C to break
    Reply from 10.1.2.1: bytes=1401 Sequence=1 ttl=255 time=50 ms
    Reply from 10.1.2.1: bytes=1401 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=1401 Sequence=3 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=1401 Sequence=4 ttl=255 time=10 ms
    Reply from 10.1.2.1: bytes=1401 Sequence=5 ttl=255 time=20 ms
  --- 10.1.2.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/26/50 ms

再次查看RouterB接口统计信息

<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:25:33-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Output peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:25:56-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 192 bits/sec, 0 packets/sec
Last 300 seconds output rate 192 bits/sec, 0 packets/sec
Input peak rate 11640 bits/sec,Record time: 2025-06-16 21:25:14
Output peak rate 11640 bits/sec,Record time: 2025-06-16 21:25:14
Input:  6 packets, 7275 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                1,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  6 packets, 7275 bytes
  Unicast:                  6,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

      比较执行命令ping -s 1401 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet0/0/1发送报文总数量增加了6(其中一个是ARP应答报文),即RouterB接口GigabitEthernet0/0/1在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.2.2抓包效果如下图所示

针对其他长度范围内的报文,验证其下一跳路由配置的正确性

默认ping报文大小

#缺省报文长度是56字节
<RouterA>ping 10.1.2.1
  PING 10.1.2.1: 56  data bytes, press CTRL_C to break
    Reply from 10.1.2.1: bytes=56 Sequence=1 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.2.1: bytes=56 Sequence=5 ttl=255 time=10 ms
  --- 10.1.2.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/18/20 ms
<RouterB>reset counters interface gigabitethernet 0/0/0
Info: Reset successfully.
<RouterB>reset counters interface gigabitethernet 0/0/1
Info: Reset successfully.
<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:31:20-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 8 bits/sec, 0 packets/sec
Last 300 seconds output rate 8 bits/sec, 0 packets/sec
Input peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Output peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Input:  5 packets, 490 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  5 packets, 490 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:31:25-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 13280 bits/sec,Record time: 2025-06-16 21:30:39
Output peak rate 13280 bits/sec,Record time: 2025-06-16 21:30:39
Input:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  0 packets, 0 bytes
  Unicast:                  0,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

      比较执行命令ping 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet0/0/0发送报文总数量增加了5,即RouterB接口GigabitEthernet0/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.1.2

大于1500字节的报文

#接口的最大传输单元(MTU)。例如以太网接口的缺省值是1500字节。长度大于MTU的报文,将会被分片后再发送。如果设置了不准分片,会被丢弃。
<RouterA>ping -s 1600 10.1.2.1
  PING 10.1.2.1: 1600  data bytes, press CTRL_C to break
    Reply from 10.1.2.1: bytes=1600 Sequence=1 ttl=255 time=40 ms
    Reply from 10.1.2.1: bytes=1600 Sequence=2 ttl=255 time=40 ms
    Reply from 10.1.2.1: bytes=1600 Sequence=3 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=1600 Sequence=4 ttl=255 time=30 ms
    Reply from 10.1.2.1: bytes=1600 Sequence=5 ttl=255 time=40 ms
  --- 10.1.2.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/36/40 ms
<RouterB>display interface GigabitEthernet 0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/0 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.1.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2242
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:32:32-08:00
Port Mode: FORCE COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 8 bits/sec, 0 packets/sec
Last 300 seconds output rate 8 bits/sec, 0 packets/sec
Input peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Output peak rate 1072 bits/sec,Record time: 2025-06-16 21:14:49
Input:  5 packets, 490 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  5 packets, 490 bytes
  Unicast:                  5,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%
<RouterB>display interface GigabitEthernet 0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2025-06-16 21:06:21 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 Interface
Route Port,The Maximum Transmit Unit is 1500
Internet Address is 192.168.2.2/24
IP Sending Frames' Format is PKTFMT_ETHNT_2, Hardware address is 00e0-fcf2-2243
Last physical up time   : 2025-06-16 21:04:39 UTC-08:00
Last physical down time : 2025-06-16 21:04:32 UTC-08:00
Current system time: 2025-06-16 21:32:29-08:00
Port Mode: COMMON COPPER
Speed : 1000,  Loopback: NONE
Duplex: FULL,  Negotiation: ENABLE
Mdi   : AUTO
Last 300 seconds input rate 0 bits/sec, 0 packets/sec
Last 300 seconds output rate 0 bits/sec, 0 packets/sec
Input peak rate 13280 bits/sec,Record time: 2025-06-16 21:30:39
Output peak rate 13280 bits/sec,Record time: 2025-06-16 21:30:39
Input:  10 packets, 8380 bytes
  Unicast:                 10,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  CRC:                      0,  Giants:                      0
  Jabbers:                  0,  Throttles:                   0
  Runts:                    0,  Symbols:                     0
  Ignoreds:                 0,  Frames:                      0
Output:  10 packets, 8380 bytes
  Unicast:                 10,  Multicast:                   0
  Broadcast:                0,  Jumbo:                       0
  Discard:                  0,  Total Error:                 0
  Collisions:               0,  ExcessiveCollisions:         0
  Late Collisions:          0,  Deferreds:                   0
    Input bandwidth utilization threshold : 100.00%
    Output bandwidth utilization threshold: 100.00%
    Input bandwidth utilization  :    0%
    Output bandwidth utilization :    0%

      比较执行命令ping -s 1600 10.1.2.1与前后RouterB接口统计信息,只有RouterB接口GigabitEthernet0/0/1发送报文总数量增加了10(长度大于MTU的报文,将会被分片后再发送),即RouterB接口GigabitEthernet0/0/1在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.2.2

实验总结

  1. 策略路由规则
  • 64-1400字节:强制下一跳为 192.168.1.2
  • 1401-1500字节:强制下一跳为 192.168.2.2
  • 其他长度:按目的地址常规路由,若存在优先级相同的静态路由则负载分担。
  1. 测试验证结果

测试命令

下一跳地址

关键现象

ping -s 80 10.1.2.1

192.168.1.2

GE0/0/0 发送量 +6(含1 ARP + 5 ICMP应答)

ping -s 1401 10.1.2.1

192.168.2.2

GE0/0/1 发送量 +6(含1 ARP + 5 ICMP应答)

ping 10.1.2.1

192.168.1.2

GE0/0/0 发送量 +5(默认长度 <64 字节)

ping -s 1600 10.1.2.1

192.168.2.2

GE0/0/1 发送量 +10(分片后5应答*2)

  1. 核心结论
  • 策略路由优先级最高:报文长度匹配策略时,强制按指定下一跳转发(覆盖常规路由)。
  • 长度超MTU触发分片:1600字节报文因分片导致应答统计翻倍(分片后每个ICMP应答需多个报文)。
  • 未匹配策略时负载分担:当报文长度不在策略范围内(如默认ping的60字节),由优先级相同的静态路由实现负载均衡。
  1. 验证逻辑
          通过对比接口统计增量或抓包查看,反向推算出实际选择的下一跳地址,证实策略路由按报文长度精确生效。
相关文章
|
1月前
|
缓存 自然语言处理 数据可视化
阿里云百炼产品月刊【2025年7月】
阿里云百炼平台7月推出多项更新与活动,。通义大模型家族迎来五连发升级,推出Qwen-Plus-2025-07-28快照模型,支持1M上下文长度,新增Qwen3-Coder-Plus,具备强大Coding Agent能力。同时,通义万相2.2系列全面升级,文生图、文生视频能力大幅提升。多项模型限时优惠,Qwen3-Coder-Plus最高享5折,Qwen-Plus、Qwen-Turbo价格下调50%,Qwen-MT-Plus降价80%。应用模块新增UI设计器,支持可视化构建Web App。另有多种活动上线,包括Agent创客实训、Qwen3-Coder挑战赛及全栈焕新课程。
479 2
|
3月前
|
存储 Web App开发 缓存
清理C盘空间的6种方法,附详细操作步骤
释放C盘空间并不难。只要掌握合适的方法,哪怕你是电脑小白,也能轻松清理出几十GB空间。下面就为大家介绍6种实用、安全、细致的清理方法,并附上操作步骤。
|
4月前
|
机器学习/深度学习 存储 安全
4G手机内存玩转Qwen2.5-Omni?MNN全面支持Qwen2.5-Omni与Qwen3!
随着移动端算力、存储能力的提升,在端侧部署大模型已成为趋势。本地化运行可消除网络延迟实现毫秒响应,降低云端算力成本,同时避免数据上传保障隐私安全。
1053 1
|
数据采集 数据可视化 定位技术
阿里云百炼智能体与工作流深度联动,打造更灵活的AI+流程开发体验
阿里云百炼平台推出智能体与工作流相互调用功能,支持四种灵活嵌套模式,提升复杂业务流程的复用与自动化能力。通过组件化封装,用户可在智能体中调用工作流,或在工作流中嵌套智能体,显著提高开发效率与系统灵活性,适用于不同技术水平的开发者。
777 0
|
存储 弹性计算 网络安全
阿里云云计算专业认证考试(Alibaba Cloud Certified Professional,ACP)
认证介绍 阿里云云计算专业认证(ACP级-Alibaba Cloud Certified Professional)是面向使用阿里云云计算产品的架构、开发、运维类人员的专业技术认证,主要涉及阿里云的计算、存储、网络、安全类的核心产品。
|
3月前
|
存储 运维 监控
zk基础—3.集群与核心参数
本文详细介绍了ZooKeeper(zk)的单机与集群部署方式、机器配置要求、JVM参数设置、核心配置参数、数据快照与事务日志机制、Leader选举相关参数、客户端连接限制、节点存储限制、端口通信、数据文件清理策略、事务日志风险控制、运维命令等内容,帮助读者全面掌握ZooKeeper的部署、调优和日常运维操作。
|
3月前
|
数据安全/隐私保护 Android开发 Windows
2025 年三款免费高清无水印视频录制工具推荐合集
本文介绍了三款免费高清录屏软件:EVCapture、Bandicam 和 屏幕录像机(oCam)。EVCapture 功能强大,支持视频录制与直播,提供分屏录制、实时按键显示等;Bandicam 适合游戏录屏,可自定义录制区域并添加Logo,还支持音频和摄像头设置;oCam 小巧灵活,支持多种视频格式(如GIF、MP4等)及音频、截图功能。三者均无水印,画质清晰,满足不同录屏需求。资源地址已提供,可供下载体验。
2564 0
|
11月前
|
Ubuntu Linux 测试技术
Linux系统之部署轻量级Markdown文本编辑器
【10月更文挑战第6天】Linux系统之部署轻量级Markdown文本编辑器
509 1
Linux系统之部署轻量级Markdown文本编辑器
|
7月前
|
Linux UED C++
MarkEdit:相信做技术的同学都会喜欢这个编辑器的,MarkEdit编辑器,让Markdown编辑变得简单而强大,超赞~~~
嗨,大家好,我是小华同学。MarkEdit是一款跨平台的Markdown编辑器,支持Windows、macOS和Linux,提供实时预览、快捷键、自定义主题和插件系统等核心功能。它适用于日常笔记、技术文档、博客写作、学术论文和电子书制作等多种场景。
376 31
|
10月前
|
存储 关系型数据库 分布式数据库
PolarDB的PolarStore存储引擎以其高效的索引结构、优化的数据压缩算法、出色的事务处理能力著称
PolarDB的PolarStore存储引擎以其高效的索引结构、优化的数据压缩算法、出色的事务处理能力著称。本文深入解析PolarStore的内部机制及优化策略,包括合理调整索引、优化数据分布、控制事务规模等,旨在最大化其性能优势,提升数据存储与访问效率。
199 5

热门文章

最新文章