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

简介: 本文介绍了一种基于报文长度的策略路由配置方案,实现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. 验证逻辑
          通过对比接口统计增量或抓包查看,反向推算出实际选择的下一跳地址,证实策略路由按报文长度精确生效。
相关文章
|
14天前
|
人工智能 自然语言处理 关系型数据库
如何构建和调优高可用性的Agent?浅谈阿里云服务领域Agent构建的方法论
本文深入探讨了Agent智能体的概念、技术挑战及实际落地方法,涵盖了从狭义到广义的Agent定义、构建过程中的四大挑战(效果不稳定、规划权衡、领域知识集成、响应速度),并提出了相应的解决方案。文章结合阿里云服务领域的实践经验,总结了Agent构建与调优的完整路径,为推动Agent在To B领域的应用提供了有价值的参考。
209 18
如何构建和调优高可用性的Agent?浅谈阿里云服务领域Agent构建的方法论
|
1月前
|
存储 Web App开发 缓存
清理C盘空间的6种方法,附详细操作步骤
释放C盘空间并不难。只要掌握合适的方法,哪怕你是电脑小白,也能轻松清理出几十GB空间。下面就为大家介绍6种实用、安全、细致的清理方法,并附上操作步骤。
|
29天前
|
Linux 虚拟化 iOS开发
macOS Tahoe 26 beta (25A5279m) Boot ISO 原版可引导镜像下载
macOS Tahoe 26 beta (25A5279m) Boot ISO 原版可引导镜像下载
559 8
macOS Tahoe 26 beta (25A5279m) Boot ISO 原版可引导镜像下载
|
14天前
|
人工智能 监控 中间件
深入解析|Cursor编程实践经验分享
本文是近两个月的实践总结,结合在实际工作中的实践聊一聊Cursor的表现。记录在该过程中遇到的问题以及一些解法。问题概览(for 服务端): 不如我写的快?写的不符合预期? Cursor能完成哪些需求?这个需求可以用Cursor,那个需求不能用Cursor? 历史代码分析浅显,不够深入理解? 技术方案设计做的不够好,细节缺失,生成代码的可用性不够满意?
深入解析|Cursor编程实践经验分享
|
2月前
|
机器学习/深度学习 存储 安全
4G手机内存玩转Qwen2.5-Omni?MNN全面支持Qwen2.5-Omni与Qwen3!
随着移动端算力、存储能力的提升,在端侧部署大模型已成为趋势。本地化运行可消除网络延迟实现毫秒响应,降低云端算力成本,同时避免数据上传保障隐私安全。
621 1
|
1月前
|
数据安全/隐私保护 Android开发 Windows
2025 年三款免费高清无水印视频录制工具推荐合集
本文介绍了三款免费高清录屏软件:EVCapture、Bandicam 和 屏幕录像机(oCam)。EVCapture 功能强大,支持视频录制与直播,提供分屏录制、实时按键显示等;Bandicam 适合游戏录屏,可自定义录制区域并添加Logo,还支持音频和摄像头设置;oCam 小巧灵活,支持多种视频格式(如GIF、MP4等)及音频、截图功能。三者均无水印,画质清晰,满足不同录屏需求。资源地址已提供,可供下载体验。
1157 0
|
1月前
|
机器学习/深度学习 人工智能 自然语言处理
已解决: gemini国内能用吗?回答是: 能用!
技术的飞速发展,各大科技公司持续推动技术边界的拓展
1834 11
|
4月前
|
SQL 分布式计算 数据挖掘
从湖仓分离到湖仓一体,四川航空基于 SelectDB 的多源数据联邦分析实践
川航选择引入 SelectDB 建设湖仓一体大数据分析引擎,取得了数据导入效率提升 3-6 倍,查询分析性能提升 10-18 倍、实时性提升至 5 秒内等收益。
从湖仓分离到湖仓一体,四川航空基于 SelectDB 的多源数据联邦分析实践
|
1月前
|
XML Java 应用服务中间件
在centos7.x上安装配置tomcat
本指南介绍了在Linux系统中部署Tomcat服务器的完整流程,包括关闭防火墙与SELinux、安装JDK、下载及解压Tomcat、启动和关闭Tomcat服务,以及配置Tomcat管理功能。同时,详细描述了如何导入项目到Tomcat的webapps目录、修改配置文件,并测试项目访问。通过这些步骤,您可以成功搭建并运行一个基于Tomcat的Web应用环境。