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

简介: 本文介绍了一种基于报文长度的策略路由配置方案,实现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. 验证逻辑
          通过对比接口统计增量或抓包查看,反向推算出实际选择的下一跳地址,证实策略路由按报文长度精确生效。
相关文章
|
11月前
|
网络虚拟化
配置OptionC方式跨域VPN示例
本文介绍了跨域BGP/MPLS IP VPN的配置方法。公司总部(CE1)与分部(CE2)分别通过不同运营商AS10和AS20接入,同属vpn1。配置思路包括:1) 配置IGP协议实现骨干网互通;2) 配置MPLS基本能力和LDP建立LSP;3) 配置VPN实例并绑定接口;4) 建立EBGP对等体交换路由;5) 在ASBR-PE上发布带标签的路由;6) 配置MP-EBGP对等体关系。操作步骤涵盖IP地址配置、MPLS骨干网互通、VPN实例接入及路由验证,确保跨域通信正常。
|
8月前
|
Oracle 关系型数据库 虚拟化
在VMware的Win10虚拟机中安装使用ENSP
本文介绍了在Windows 10虚拟机上安装ENSP及相关软件的全过程,包括VirtualBox、WinPcap、Wireshark、VLC和ENSP的安装步骤,并提供图文演示,帮助用户顺利完成配置与测试。
2202 134
|
8月前
|
人工智能 运维 安全
从“裸奔”到“金钟罩”:AI身份凭据安全的进化之路
构建身份权限安全,护航企业数据合规
1881 37
|
1月前
|
人工智能 架构师
Qoder Together 郑州站来啦!解锁企业级 AI Coding 落地玩法
4月22日14:00-17:00,郑州阿里中心举办AI Coding实战沙龙!聚焦Qoder产品解析、企业级方案及UU跑腿落地实践,架构师现场带练。名额有限,速报名→ https://huodongxing.com/event/4855877137411
156 4
|
11月前
|
JSON 自然语言处理 Linux
linux命令—tree
tree是一款强大的Linux命令行工具,用于以树状结构递归展示目录和文件,直观呈现层级关系。支持多种功能,如过滤、排序、权限显示及格式化输出等。安装方法因系统而异常用场景包括:基础用法(显示当前或指定目录结构)、核心参数应用(如层级控制-L、隐藏文件显示-a、完整路径输出-f)以及进阶操作(如磁盘空间分析--du、结合grep过滤内容、生成JSON格式列表-J等)。此外,还可生成网站目录结构图并导出为HTML文件。注意事项:使用Tab键补全路径避免错误;超大目录建议限制遍历层数;脚本中推荐禁用统计信息以优化性能。更多详情可查阅手册mantree。
967 143
linux命令—tree
|
8月前
|
存储 虚拟化 Windows
VMware安装Windows10
本案例介绍了在Windows系统上使用VMware Workstation 17.5 Pro安装配置Windows 10虚拟机的详细步骤,包括所需设备、软件下载链接、虚拟机设置及系统安装全过程。
6001 134
VMware安装Windows10
|
11月前
|
人工智能 监控 中间件
深入解析|Cursor编程实践经验分享
本文是近两个月的实践总结,结合在实际工作中的实践聊一聊Cursor的表现。记录在该过程中遇到的问题以及一些解法。问题概览(for 服务端): 不如我写的快?写的不符合预期? Cursor能完成哪些需求?这个需求可以用Cursor,那个需求不能用Cursor? 历史代码分析浅显,不够深入理解? 技术方案设计做的不够好,细节缺失,生成代码的可用性不够满意?
2088 11
深入解析|Cursor编程实践经验分享
|
11月前
|
网络协议 网络虚拟化 网络架构
综合实验案例
本文档详细描述了一个网络实验的配置方案,包括实验拓扑、IP与VLAN划分、MSTP配置、OSPFv2内部路由配置、出口路由与Internet模拟配置、VRRP配置以及DHCP配置。实验涉及AR1、AR2、CSW1、CSW2等多台设备,涵盖了核心路由器、接入交换机和DHCP服务器的设置。通过静态路由、动态路由协议(OSPF)、生成树协议(MSTP)、虚拟路由冗余协议(VRRP)及DHCP服务的综合应用,实现网络内部互访、Internet访问及高可用性验证。最后,通过一系列ping测试验证各服务功能是否正常运行,确保网络的稳定性和可靠性。
综合实验案例
|
12月前
|
人工智能 安全 算法
|
移动开发 安全 虚拟化
VMware ESXi 7.0 U3r 下载 - 领先的裸机 Hypervisor
VMware ESXi 7.0 U3r 下载 - 领先的裸机 Hypervisor
874 0
VMware ESXi 7.0 U3r 下载 - 领先的裸机 Hypervisor