通过策略路由控制Switch A产生的报文:
· 指定所有TCP报文的下一跳为1.1.2.2;
· 其它报文仍然按照查找路由表的方式进行转发。
其中,Switch A分别与Switch B和Switch C直连。
system-view
[SwitchA] vlan 10
[SwitchA-vlan10] quit
[SwitchA] vlan 20
[SwitchA-vlan20] quit
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] ip address 1.1.2.1 24
[SwitchA-Vlan-interface10] quit
[SwitchA] interface vlan-interface 20
[SwitchA-Vlan-interface20] ip address 1.1.3.1 24
[SwitchA-Vlan-interface20] quit
[SwitchA] acl number 3101
[SwitchA-acl-adv-3101] rule permit tcp
[SwitchA-acl-adv-3101] quit
[SwitchA] policy-based-route aaa permit node 5
[SwitchA-pbr-aaa-5] if-match acl 3101
[SwitchA-pbr-aaa-5] apply next-hop 1.1.2.2
[SwitchA-pbr-aaa-5] quit
[SwitchA] ip local policy-based-route aaa
(2) 配置Switch B
system-view
[SwitchB] vlan 10
[SwitchB-vlan10] quit
[SwitchB] interface vlan-interface 10
[SwitchB-Vlan-interface10] ip address 1.1.2.2 24
(3) 配置Switch C
#创建VLAN 20
system-view
[SwitchC] vlan 20
[SwitchC-vlan20] quit
[SwitchC] interface vlan-interface 20
[SwitchC-Vlan-interface20] ip address 1.1.3.2 24
从Switch A上通过Telnet方式登录Switch C(1.1.3.2/24),结果失败。
从Switch A上ping Switch C(1.1.3.2/24),结果成功。
由于Telnet使用的是TCP协议,ping使用的是ICMP协议,所以由以上结果可证明:Switch A发出的TCP报文的下一跳为1.1.2.2,接口Vlan-interface20不发送TCP报文,但可以发送非TCP报文,策略路由设置成功。
1.6.2 基于报文协议类型的转发策略路由配置举例
· 指定所有TCP报文的下一跳为1.1.2.2;
· 其它报文仍然按照查找路由表的方式进行转发。
组网图
图1-2 基于报文协议类型的转发策略路由的配置举例组网图
配置步骤
(1) 配置Switch A
system-view
[SwitchA] vlan 10
[SwitchA-vlan10] quit
[SwitchA] vlan 20
[SwitchA-vlan20] quit
[SwitchA] interface vlan-interface 10
[SwitchA-Vlan-interface10] ip address 1.1.2.1 24
[SwitchA-Vlan-interface10] quit
[SwitchA] interface vlan-interface 20
[SwitchA-Vlan-interface20] ip address 1.1.3.1 24
[SwitchA-Vlan-interface20] quit
[SwitchA] acl number 3101
[SwitchA-acl-adv-3101] rule permit tcp
[SwitchA-acl-adv-3101] quit
[SwitchA] policy-based-route aaa permit node 5
[SwitchA-pbr-aaa-5] if-match acl 3101
[SwitchA-pbr-aaa-5] apply next-hop 1.1.2.2
[SwitchA-pbr-aaa-5] quit
[SwitchA] interface vlan-interface 11
[SwitchA-Vlan-interface11] ip address 10.110.0.10 24
[SwitchA-Vlan-interface11] ip policy-based-route aaa
[SwitchA-Vlan-interface11] quit
(2) 配置Switch B
system-view
[SwitchB] vlan 10
[SwitchB-vlan10] quit
[SwitchB] interface vlan-interface 10
[SwitchB-Vlan-interface10] ip address 1.1.2.2 24
[SwitchB-Vlan-interface10] quit
[SwitchB] ip route-static 10.110.0.0 24 1.1.2.1
(3) 配置Switch C
#创建VLAN 20
system-view
[SwitchC] vlan 20
[SwitchC-vlan20] quit
[SwitchC] interface vlan-interface 20
[SwitchC-Vlan-interface20] ip address 1.1.3.2 24
[SwitchC-Vlan-interface20] quit
[SwitchC] ip route-static 10.110.0.0 24 1.1.3.1
从Host A上通过Telnet方式登录Switch B,结果成功。
从Host A上通过Telnet方式登录Switch C,结果失败。
从Host A上ping Switch C,结果成功。
由于Telnet使用的是TCP协议,ping使用的是ICMP协议,所以由以上结果可证明:从Switch A的接口Vlan-interface11接收的TCP报文的下一跳为1.1.2.2,接口Vlan-interface20不转发TCP报文,但可以转发非TCP报文,策略路由设置成功。
策略路由显示和维护
显示已经配置的策略
display ip policy-based-route [ policy policy-name ]
显示已经应用的策略路由信息
display ip policy-based-route setup
显示本地策略路由的配置信息和统计信息
display ip policy-based-route local
显示接口下转发策略路由的配置信息和统计信息
display ip policy-based-route interface interface-type interface-number
清除策略路由的统计信息
reset ip policy-based-route statistics [ policy policy-name ]