单播基于报文长度的接口策略路由配置举例
1. 组网需求
通过策略路由控制从Router A的以太网接口Ethernet1/1接收的报文:
l 长度为64~100字节的报文以150.1.1.2/24作为下一跳IP地址;
l 长度为101~1000字节的报文以151.1.1.2/24作为下一跳IP地址;
l 所有其它长度的报文都按照查找路由表的方式转发。
3. 配置步骤
本例中采用动态路由协议RIP保证各设备之间路由可达。
(1) 配置Router A
# 配置动态路由协议RIP。
<RouterA> system-view
[RouterA] rip
[RouterA-rip-1] network 192.1.1.0
[RouterA-rip-1] network 150.1.0.0
[RouterA-rip-1] network 151.1.0.0
[RouterA-rip-1] quit
# 配置策略lab1,将长度为64~100字节的报文转发到下一跳150.1.1.2,而将长度为101~1000字节的报文转发到下一跳151.1.1.2。
[RouterA] policy-based-route lab1 permit node 10
[RouterA-pbr-lab1-10] if-match packet-length 64 100
[RouterA-pbr-lab1-10] apply ip-address next-hop 150.1.1.2
[RouterA-pbr-lab1-10] quit
[RouterA] policy-based-route lab1 permit node 20
[RouterA-pbr-lab1-20] if-match packet-length 101 1000
[RouterA-pbr-lab1-20] apply ip-address next-hop 151.1.1.2
[RouterA-pbr-lab1-20] quit
# 在以太网接口Ethernet1/1上应用定义的策略lab1,处理此接口接收的报文。
[RouterA] interface ethernet 1/1
[RouterA-Ethernet1/1] ip address 192.1.1.1 255.255.255.0
[RouterA-Ethernet1/1] ip policy-based-route lab1
[RouterA-Ethernet1/1] quit
# 配置Serial接口的IP地址。
[RouterA] interface serial 2/0
[RouterA-Serial2/0] ip address 150.1.1.1 255.255.255.0
[RouterA-Serial2/0] quit
[RouterA] interface serial 2/1
[RouterA-Serial2/1] ip address 151.1.1.1 255.255.255.0
[RouterA-Serial2/1] quit
(2) 配置Router B
# 配置动态路由协议RIP。
<RouterB> system-view
[RouterB] rip
[RouterB-rip-1] network 10.0.0.0
[RouterB-rip-1] network 150.1.0.0
[RouterB-rip-1] network 151.1.0.0
# 配置Serial接口的IP地址。
[RouterB] interface serial 2/0
[RouterB-Serial2/0] ip address 150.1.1.2 255.255.255.0
[RouterB-Serial2/0] quit
[RouterB] interface serial 2/1
[RouterB-Serial2/1] ip address 151.1.1.2 255.255.255.0
[RouterB-Serial2/1] quit
# 配置Loopback接口的IP地址。
[RouterB] interface loopback 0
[RouterB-LoopBack0] ip address 10.1.1.1 32
(3) 验证配置结果
# 在Router A上用debugging ip policy-based-route命令监视策略路由。
<RouterA> debugging ip policy-based-route
<RouterA> terminal debugging
<RouterA> terminal monitor
将Host A的IP地址配置为192.1.1.3/24,网关地址配置为192.1.1.1。
# 从Host A上Ping Router B的Loopback0,并将报文数据字段长度设为50字节。
C:\>ping -l 50 10.1.1.1
Pinging 10.1.1.1 with 50 bytes of data:
Reply from 10.1.1.1: bytes=50 time<1ms TTL=255
Reply from 10.1.1.1: bytes=50 time<1ms TTL=255
Reply from 10.1.1.1: bytes=50 time<1ms TTL=255
Reply from 10.1.1.1: bytes=50 time<1ms TTL=255
Ping statistics for 10.1.1.1:
Packets: Sent = 4, Received = 4, Lost =
0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
从Router A上显示的策略路由调试信息如下:
<RouterA>
*Jun 7 12:04:33:519 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 10, next-hop : 150.1.1.2
*Jun 7 12:04:34:518 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 10, next-hop : 150.1.1.2
*Jun 7 12:04:35:518 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 10, next-hop : 150.1.1.2
*Jun 7 12:04:36:518 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 10, next-hop : 150.1.1.2
以上策略路由信息显示,Router A在接收到报文后,根据策略路由确定的下一跳为150.1.1.2,也就是说将报文从接口Serial2/0转发出去。
# 从Host A上Ping Router B的Loopback0,并将报文数据字段长度设为200字节。
C:\>ping -l 200 10.1.1.1
Pinging 10.1.1.1 with 200 bytes of data:
Reply from 10.1.1.1: bytes=200 time<1ms TTL=255
Reply from 10.1.1.1: bytes=200 time<1ms TTL=255
Reply from 10.1.1.1: bytes=200 time<1ms TTL=255
Reply from 10.1.1.1: bytes=200 time<1ms TTL=255
Ping statistics for 10.1.1.1:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 0ms, Maximum = 0ms, Average = 0ms
从Router A上显示的策略路由调试信息如下:
<RouterA>
*Jun 7 12:06:47:631 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 20, next-hop : 151.1.1.2
*Jun 7 12:06:48:630 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 20, next-hop : 151.1.1.2
*Jun 7 12:06:49:627 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 20, next-hop : 151.1.1.2
*Jun 7 12:06:50:627 2009 RouterA PBR/7/POLICY-ROUTING: IP policy based routing
success : POLICY_ROUTEMAP : lab1, Node : 20, next-hop : 151.1.1.2
以上策略路由信息显示,Router A在接收到报文后,根据策略路由确定的下一跳为151.1.1.2,也就是说将报文从接口Serial2/1转发出去。