组网需求
RouterA与RouterB间有两条链路相连。
用户希望实现本机下发的不同长度的报文通过不同的下一跳地址进行转发,其中:
- 长度为64~1400字节的报文设置192.168.1.2作为下一跳地址。
- 长度为1401~1500字节的报文设置192.168.2.2作为下一跳地址。
- 所有其它长度的报文都按基于目的地址的方法进行路由选路。
- 策略路由与路由策略(Routing Policy)存在以下不同:
- 策略路由的操作对象是数据包,在路由表已经产生的情况下,不按照路由表进行转发,而是根据需要,依照某种策略改变数据包转发路径。
- 路由策略的操作对象是路由信息。路由策略主要实现了路由过滤和路由属性设置等功能,它通过改变路由属性(包括可达性)来改变网络流量所经过的路径。
配置思路
采用如下思路配置本地策略路由:
- 在RouterA上配置IP报文长度匹配条件,以实现本机下发的不同长度的报文匹配不同的策略点。
- 在RouterA上配置本地策略路由的动作,以实现本机下发的不同长度的报文通过不同的下一跳地址进行转发。
- 使能本地策略路由。
操作步骤
配置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。
实验总结
- 策略路由规则
- 64-1400字节:强制下一跳为 192.168.1.2
- 1401-1500字节:强制下一跳为 192.168.2.2
- 其他长度:按目的地址常规路由,若存在优先级相同的静态路由则负载分担。
- 测试验证结果
测试命令 |
下一跳地址 |
关键现象 |
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) |
- 核心结论
- 策略路由优先级最高:报文长度匹配策略时,强制按指定下一跳转发(覆盖常规路由)。
- 长度超MTU触发分片:1600字节报文因分片导致应答统计翻倍(分片后每个ICMP应答需多个报文)。
- 未匹配策略时负载分担:当报文长度不在策略范围内(如默认ping的60字节),由优先级相同的静态路由实现负载均衡。
- 验证逻辑
通过对比接口统计增量或抓包查看,反向推算出实际选择的下一跳地址,证实策略路由按报文长度精确生效。