https://support.huawei.com/enterprise/zh/doc/EDOC1100212541/3ffa4898
配置本地策略路由示例
组网需求
如图12-10所示,RouterA与RouterB间有两条链路相连。
长度为64~1400字节的报文设置192.168.1.2作为下一跳地址。
长度为1401~1500字节的报文设置192.168.2.2作为下一跳地址。
所有其它长度的报文都按基于目的地址的方法进行路由选路。
操作步骤
配置各接口的IP地址
# 配置RouterA的各接口的IP地址。
<Huawei> system-view[Huawei] sysname RouterA[RouterA] interface gigabitethernet 1/0/0[RouterA-GigabitEthernet1/0/0] ip address 192.168.1.1 255.255.255.0[RouterA-GigabitEthernet1/0/0] quit[RouterA] interface gigabitethernet 2/0/0[RouterA-GigabitEthernet2/0/0] ip address 192.168.2.1 255.255.255.0[RouterA-GigabitEthernet2/0/0] quit[RouterA] interface loopback 0[RouterA-LoopBack0] ip address 10.1.1.1 255.255.255.0[RouterA-LoopBack0] quit
# 配置RouterB的各接口的IP地址。
<Huawei> system-view[Huawei] sysname RouterB[RouterB] interface gigabitethernet 1/0/0[RouterB-GigabitEthernet1/0/0] ip address 192.168.1.2 255.255.255.0[RouterB-GigabitEthernet1/0/0] quit[RouterB] interface gigabitethernet 2/0/0[RouterB-GigabitEthernet2/0/0] ip address 192.168.2.2 255.255.255.0[RouterB-GigabitEthernet2/0/0] quit[RouterB] interface loopback 0[RouterB-LoopBack0] ip address 10.1.2.1 255.255.255.0[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
配置策略路由
# 配置名称为lab1的策略路由。
[RouterA] policy-based-route lab1 permit node 10[RouterA-policy-based-route-lab1-10] if-match packet-length 64 1400[RouterA-policy-based-route-lab1-10] apply ip-address next-hop 192.168.1.2[RouterA-policy-based-route-lab1-10] quit[RouterA] policy-based-route lab1 permit node 20[RouterA-policy-based-route-lab1-20] if-match packet-length 1401 1500[RouterA-policy-based-route-lab1-20] apply ip-address next-hop 192.168.2.2[RouterA-policy-based-route-lab1-20] quit
# 使能本地策略路由。
[RouterA] ip local policy-based-route lab1
验证配置结果
# 清空RouterB接口统计信息。
<RouterB> reset counters interface gigabitethernet 1/0/0
<RouterB> reset counters interface gigabitethernet 2/0/0
# 查看RouterB接口统计信息。
<RouterB> display interface gigabitethernet 1/0/0 GigabitEthernet1/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:24 Description:HUAWEI, AR Series, GigabitEthernet1/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-fcce-7d4c Last physical up time : 2012-07-30 11:23:24 Last physical down time : 2012-07-24 16:54:19 Current system time: 2012-07-30 14:57:28 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : - 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 0 bits/sec,Record time: 2012-07-30 12:57:02 Output peak rate 0 bits/sec,Record time: 2012-07-30 12:42:42 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.01% Output bandwidth utilization : 0.01%
<RouterB> display interface gigabitethernet 2/0/0GigabitEthernet2/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:29 Description:HUAWEI, AR Series, GigabitEthernet2/0/0 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-fcce-7d4d Last physical up time : 2012-07-30 11:23:29 Last physical down time : 2012-07-30 11:09:17 Current system time: 2012-07-30 14:58:24 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : SLAVE 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 0 bits/sec,Record time: 2012-07-30 13:46:52 Output peak rate 0 bits/sec,Record time: 2012-07-30 13:46:52 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.01% Output bandwidth utilization : 0.01%
# 在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=2 ms Reply from 10.1.2.1: bytes=80 Sequence=2 ttl=255 time=2 ms Reply from 10.1.2.1: bytes=80 Sequence=3 ttl=255 time=2 ms Reply from 10.1.2.1: bytes=80 Sequence=4 ttl=255 time=2 ms Reply from 10.1.2.1: bytes=80 Sequence=5 ttl=255 time=2 ms --- 10.1.2.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 2/2/2 ms
# 查看RouterB接口统计信息。
<RouterB> display interface gigabitethernet 1/0/0 GigabitEthernet1/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:24 Description:HUAWEI, AR Series, GigabitEthernet1/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-fcce-7d4c Last physical up time : 2012-07-30 11:23:24 Last physical down time : 2012-07-24 16:54:19 Current system time: 2012-07-30 15:00:15 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : - Last 300 seconds input rate 24 bits/sec, 0 packets/sec Last 300 seconds output rate 24 bits/sec, 0 packets/sec Input peak rate 504 bits/sec,Record time: 2012-07-30 12:57:02 Output peak rate 504 bits/sec,Record time: 2012-07-30 12:42:42 Input: 5 packets, 400 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, 400 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.01% Output bandwidth utilization : 0.01%
<RouterB> display interface gigabitethernet 2/0/0GigabitEthernet2/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:29 Description:HUAWEI, AR Series, GigabitEthernet2/0/0 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-fcce-7d4d Last physical up time : 2012-07-30 11:23:29 Last physical down time : 2012-07-30 11:09:17 Current system time: 2012-07-30 15:01:02 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : SLAVE 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 0 bits/sec,Record time: 2012-07-30 13:46:52 Output peak rate 0 bits/sec,Record time: 2012-07-30 13:46:52 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.01% Output bandwidth utilization : 0.01%
比较执行命令ping -s 80 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet 1/0/0发送报文总数量增加了5,即RouterB接口GigabitEthernet 1/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.1.2。
# 清空RouterB接口统计信息。
<RouterB> reset counters interface gigabitethernet 1/0/0
<RouterB> reset counters interface gigabitethernet 2/0/0
# 查看RouterB接口统计信息。
<RouterB> display interface gigabitethernet 1/0/0 GigabitEthernet1/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:24 Description:HUAWEI, AR Series, GigabitEthernet1/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-fcce-7d4c Last physical up time : 2012-07-30 11:23:24 Last physical down time : 2012-07-24 16:54:19 Current system time: 2012-07-30 16:04:14 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : - 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 0 bits/sec,Record time: 2012-07-30 12:57:02 Output peak rate 0 bits/sec,Record time: 2012-07-30 12:42:42 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.01% Output bandwidth utilization : 0.01%
<RouterB> display interface gigabitethernet 2/0/0GigabitEthernet2/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:29 Description:HUAWEI, AR Series, GigabitEthernet2/0/0 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-fcce-7d4d Last physical up time : 2012-07-30 11:23:29 Last physical down time : 2012-07-30 11:09:17 Current system time: 2012-07-30 16:04:19 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : SLAVE 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 0 bits/sec,Record time: 2012-07-30 13:46:52 Output peak rate 0 bits/sec,Record time: 2012-07-30 13:46:52 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.01% Output bandwidth utilization : 0.01%
# 在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=1 ms Reply from 10.1.2.1: bytes=1401 Sequence=2 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=1401 Sequence=3 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=1401 Sequence=4 ttl=255 time=1 ms Reply from 10.1.2.1: bytes=1401 Sequence=5 ttl=255 time=2 ms --- 10.1.2.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/1/2 ms
# 查看RouterB接口统计信息。
<RouterB> display interface gigabitethernet 1/0/0 GigabitEthernet1/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:24 Description:HUAWEI, AR Series, GigabitEthernet1/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-fcce-7d4c Last physical up time : 2012-07-30 11:23:24 Last physical down time : 2012-07-24 16:54:19 Current system time: 2012-07-30 16:04:50 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : - 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 0 bits/sec,Record time: 2012-07-30 12:57:02 Output peak rate 0 bits/sec,Record time: 2012-07-30 12:42:42 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.01% Output bandwidth utilization : 0.01%
<RouterB> display interface gigabitethernet 2/0/0GigabitEthernet2/0/0 current state : UP Line protocol current state : UP Last line protocol up time : 2012-07-30 11:23:29 Description:HUAWEI, AR Series, GigabitEthernet2/0/0 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-fcce-7d4d Last physical up time : 2012-07-30 11:23:29 Last physical down time : 2012-07-30 11:09:17 Current system time: 2012-07-30 16:04:55 Port Mode: COMMON COPPER Speed : 1000, Loopback: NONE Duplex: FULL, Negotiation: ENABLE Mdi : AUTO Clock : SLAVE Last 300 seconds input rate 448 bits/sec, 0 packets/sec Last 300 seconds output rate 448 bits/sec, 0 packets/sec Input peak rate 6056 bits/sec,Record time: 2012-07-30 13:46:52 Output peak rate 6056 bits/sec,Record time: 2012-07-30 13:46:52 Input: 5 packets, 7005 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, 7005 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.01% Output bandwidth utilization : 0.01%
比较执行命令ping -s 1401 10.1.2.1前后RouterB接口统计信息,只有RouterB接口GigabitEthernet 2/0/0发送报文总数量增加了5,即RouterB接口GigabitEthernet 2/0/0在接收到ICMP请求报文后给RouterA发送5个ICMP应答报文,所以RouterA根据策略路由确定的下一跳为192.168.2.2。
配置文件
RouterA的配置文件。
# sysname RouterA # interface GigabitEthernet1/0/0 ip address 192.168.1.1 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.2.1 255.255.255.0 # interface LoopBack0 ip address 10.1.1.1 255.255.255.0 # ip route-static 10.1.2.0 255.255.255.0 192.168.1.2 ip route-static 10.1.2.0 255.255.255.0 192.168.2.2 # policy-based-route lab1 permit node 10 if-match packet-length 64 1400 apply ip-address next-hop 192.168.1.2 policy-based-route lab1 permit node 20 if-match packet-length 1401 1500 apply ip-address next-hop 192.168.2.2 # ip local policy-based-route lab1
RouterB的配置文件。
# sysname RouterB # interface GigabitEthernet1/0/0 ip address 192.168.1.2 255.255.255.0 # interface GigabitEthernet2/0/0 ip address 192.168.2.2 255.255.255.0 # interface LoopBack0 ip address 10.1.2.1 255.255.255.0 # ip route-static 10.1.1.0 255.255.255.0 192.168.1.1 ip route-static 10.1.1.0 255.255.255.0 192.168.2.1
推荐本站淘宝优惠价购买喜欢的宝贝:
本文链接:https://hqyman.cn/post/4735.html 非本站原创文章欢迎转载,原创文章需保留本站地址!
休息一下~~