组网需求
RouterA与RouterB间有两条链路相连。
用户希望实现本机下发的不同长度的报文通过不同的下一跳地址进行转发,其中:
- 长度为64~1400字节的报文设置192.168.1.2作为下一跳地址。
- 长度为1401~1500字节的报文设置192.168.2.2作为下一跳地址。
- 所有其它长度的报文都按基于目的地址的方法进行路由选路。
配置思路
采用如下思路配置本地策略路由:
- 在RouterA上配置IP报文长度匹配条件,以实现本机下发的不同长度的报文匹配不同的策略点。
- 在RouterA上配置本地策略路由的动作,以实现本机下发的不同长度的报文通过不同的下一跳地址进行转发。
- 使能本地策略路由。
操作步骤
配置IP
RouterA
<Huawei>sys
[Huawei]sys RouterA
[RouterA]int g0/0/
[RouterA-GigabitEthernet0/0/0]ip address 192.168.1.1 24
[RouterA-GigabitEthernet0/0/0]quit
[RouterA]int g0/0/1
[RouterA-GigabitEthernet0/0/1]ip add 192.168.2.1 24
[RouterA-GigabitEthernet0/0/1]quit
[RouterA]int lo0
[RouterA-LoopBack0]ip address 10.1.1.1 255.255.255.0
[RouterA-LoopBack0]quit
RouterB
<Huawei>sys
[Huawei]sys RouterB
[RouterB]int g0/0/0
[RouterB-GigabitEthernet0/0/0]ip address 192.168.1.2 24
[RouterB-GigabitEthernet0/0/0]quit
[RouterB]int g0/0/1
[RouterB-GigabitEthernet0/0/1]ip address 192.168.2.2 24
[RouterB-GigabitEthernet0/0/1]quit
[RouterB]int lo0
[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的策略路由
[RouterA]policy-based-route policy-route permit node 10
[RouterA-policy-based-route-policy-route-10]if-match packet-length 64 1400
[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
使能本地策略路由
[RouterA]ip local policy-based-route policy-route
验证
清空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 : 2022-04-04 00:23:06 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 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-fcdd-5c7f
Last physical up time : 2022-04-03 22:20:07 UTC-08:00
Last physical down time : 2022-04-03 22:20:02 UTC-08:00
Current system time: 2022-04-04 00:29: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: 2022-04-04 00:20:59
Output peak rate 96 bits/sec,Record time: 2022-04-04 00:23:14Input: 0 packets, 0 bytesUnicast: 0, Multicast: 0Broadcast: 0, Jumbo: 0Discard: 0, Total Error: 0CRC: 0, Giants: 0Jabbers: 0, Throttles: 0Runts: 0, Symbols: 0Ignoreds: 0, Frames: 0Output: 0 packets, 0 bytesUnicast: 0, Multicast: 0Broadcast: 0, Jumbo: 0Discard: 0, Total Error: 0Collisions: 0, ExcessiveCollisions: 0Late Collisions: 0, Deferreds: 0Input 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 : 2022-04-04 00:32:47 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/2 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-fcdd-5c80
Last physical up time : 2022-04-04 00:32:47 UTC-08:00
Last physical down time : 2022-04-03 22:20:02 UTC-08:00
Current system time: 2022-04-04 00:35:01-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: 2022-04-04 00:32:54
Output peak rate 96 bits/sec,Record time: 2022-04-04 00:32:54Input: 1 packets, 60 bytesUnicast: 0, Multicast: 0Broadcast: 1, Jumbo: 0Discard: 0, Total Error: 0CRC: 0, Giants: 0Jabbers: 0, Throttles: 0Runts: 0, Symbols: 0Ignoreds: 0, Frames: 0Output: 1 packets, 60 bytesUnicast: 0, Multicast: 0Broadcast: 1, Jumbo: 0Discard: 0, Total Error: 0Collisions: 0, ExcessiveCollisions: 0Late Collisions: 0, Deferreds: 0Input 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.1PING 10.1.2.1: 80 data bytes, press CTRL_C to breakReply from 10.1.2.1: bytes=80 Sequence=1 ttl=255 time=70 msReply from 10.1.2.1: bytes=80 Sequence=2 ttl=255 time=20 msReply from 10.1.2.1: bytes=80 Sequence=3 ttl=255 time=20 msReply from 10.1.2.1: bytes=80 Sequence=4 ttl=255 time=30 msReply from 10.1.2.1: bytes=80 Sequence=5 ttl=255 time=30 ms--- 10.1.2.1 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/34/70 ms
再次查看RouterB接口统计信息
<RouterB>display int g0/0/0
GigabitEthernet0/0/0 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-04-04 00:33:12 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/1 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-fcdd-5c7f
Last physical up time : 2022-04-04 00:33:12 UTC-08:00
Last physical down time : 2022-04-04 00:32:43 UTC-08:00
Current system time: 2022-04-04 00:36:53-08:00
Port Mode: COMMON 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: 2022-04-04 00:36:39
Output peak rate 1072 bits/sec,Record time: 2022-04-04 00:36:39Input: 7 packets, 730 bytesUnicast: 5, Multicast: 0Broadcast: 2, Jumbo: 0Discard: 0, Total Error: 0CRC: 0, Giants: 0Jabbers: 0, Throttles: 0Runts: 0, Symbols: 0Ignoreds: 0, Frames: 0Output: 7 packets, 730 bytesUnicast: 6, Multicast: 0Broadcast: 1, Jumbo: 0Discard: 0, Total Error: 0Collisions: 0, ExcessiveCollisions: 0Late Collisions: 0, Deferreds: 0Input bandwidth utilization threshold : 100.00%Output bandwidth utilization threshold: 100.00%Input bandwidth utilization : 0%Output bandwidth utilization : 0%
<RouterB>display int g0/0/1
GigabitEthernet0/0/1 current state : UP
Line protocol current state : UP
Last line protocol up time : 2022-04-04 00:32:47 UTC-08:00
Description:HUAWEI, AR Series, GigabitEthernet0/0/2 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-fcdd-5c80
Last physical up time : 2022-04-04 00:32:47 UTC-08:00
Last physical down time : 2022-04-03 22:20:02 UTC-08:00
Current system time: 2022-04-04 00:39:10-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: 2022-04-04 00:32:54
Output peak rate 96 bits/sec,Record time: 2022-04-04 00:32:54Input: 1 packets, 60 bytesUnicast: 0, Multicast: 0Broadcast: 1, Jumbo: 0Discard: 0, Total Error: 0CRC: 0, Giants: 0Jabbers: 0, Throttles: 0Runts: 0, Symbols: 0Ignoreds: 0, Frames: 0Output: 1 packets, 60 bytesUnicast: 0, Multicast: 0Broadcast: 1, Jumbo: 0Discard: 0, Total Error: 0Collisions: 0, ExcessiveCollisions: 0Late Collisions: 0, Deferreds: 0Input bandwidth utilization threshold : 100.00%Output bandwidth utilization threshold: 100.00%Input bandwidth utilization : 0%Output bandwidth utilization : 0%
在RouterA上Ping RouterB的Loopback0,并将报文数据字段长度设为1401字节
再次查看RouterB接口统计信息
<RouterA>tracert -s 100 10.1.2.1traceroute to 10.1.2.1(10.1.2.1), max hops: 30 ,packet length: 128,press CTRL_
C to break 1 192.168.1.2 20 ms 20 ms 20 ms
<RouterA>tracert -s 1460 10.1.2.1traceroute to 10.1.2.1(10.1.2.1), max hops: 30 ,packet length: 1488,press CTRL
_C to break 1 192.168.2.2 20 ms 30 ms 20 ms