H3C交换机策略路由配置

IT海睿 295 0

# 配置Vlan-interface2的IP地址。

<Device> system-view
[Device] interface vlan-interface 2
[Device-Vlan-interface2] ip address 10.1.2.1 255.255.255.0
[Device-Vlan-interface2] quit

# 配置静态路由,保证三条路径都可达,并且缺省下一跳为10.4.1.2。

[Device] ip route-static 192.168.1.0 24 10.3.1.2
[Device] ip route-static 192.168.1.0 24 10.4.1.2 preference 40
[Device] ip route-static 192.168.1.0 24 10.5.1.2

# 定义访问控制列表ACL 3005,用于匹配源IP地址为10.2.1.1的报文。


[Device] acl advanced 3005
[Device-acl-ipv4-adv-3005] rule 0 permit ip source 10.2.1.1 0
[Device-acl-ipv4-adv-3005] quit



# 定义访问控制列表ACL 3006,用于匹配HTTP报文。


[Device] acl advanced 3006
[Device-acl-ipv4-adv-3006] rule 0 permit tcp destination-port eq www
[Device-acl-ipv4-adv-3006] quit


# 创建策略路由pbr1的0号节点,将匹配ACL 3005的报文下一跳重定向到10.5.1.2。


[Device] policy-based-route pbr1 permit node 0
[Device-pbr-pbr1-0] if-match acl 3005
[Device-pbr-pbr1-0] apply next-hop 10.5.1.2
[Device-pbr-pbr1-0] quit


# 创建策略路由pbr1的1号节点,将匹配ACL 3006的报文下一跳重定向到10.3.1.2。


[Device] policy-based-route pbr1 permit node 1
[Device-pbr-pbr1-1] if-match acl 3006
[Device-pbr-pbr1-1] apply next-hop 10.3.1.2
[Device-pbr-pbr1-1] quit


# 在Device的接口Vlan-interface2上应用策略。


[Device] interface vlan-interface 2
[Device-Vlan-interface2] ip policy-based-route pbr1
[Device-Vlan-interface2] quit


4.4  验证配置

通过display ip policy-based-route命令可以查看到当前策略路由配置已经配置成功:


[Device] display ip policy-based-route policy pbr1
Policy name: pbr1
  node 0 permit:
    if-match acl 3005
    apply next-hop 10.5.1.2
  node 1 permit:
    if-match acl 3006
    apply next-hop 10.3.1.2



# 通过tracert命令查看以下报文的转发路径(使用Tracert功能需要在中间设备上开启ICMP超时报文发送功能,在目的端开启ICMP目的不可达报文发送功能):


源IP为10.1.1.1的非HTTP报文,重定向到10.4.1.2进行转发。


<Switch> tracert -a 10.1.1.1 192.168.1.1
traceroute to 192.168.1.1 (192.168.1.1) from 10.1.1.1, 30 hops at most, 52 bytes
 each packet, press CTRL_C to break
 1  10.1.2.1 (10.1.2.1)  2.178 ms  1.364 ms  1.058 ms
 2  10.4.1.2 (10.4.1.2)  1.548 ms  1.248 ms  1.112 ms
 3  192.168.1.1 (192.168.1.1)  1.594 ms  1.321 ms  1.093 ms


源IP为10.2.1.1的报文,重定向到10.5.1.2进行转发。


<Switch> tracert -a 10.2.1.1 192.168.1.1
traceroute to 192.168.1.1 (192.168.1.1) from 10.2.1.1, 30 hops at most, 40 bytes
 each packet, press CTRL_C to break
 1  10.1.2.1 (10.1.2.1)  1.721 ms  1.226 ms  1.050 ms
 2  10.5.1.2 (10.5.1.2)  4.494 ms  1.385 ms  1.170 ms
 3  192.168.1.1 (192.168.1.1)  1.448 ms  1.304 ms  1.093 ms


4.5  配置文件

#
vlan 1
#
vlan 2 to 5
#
policy-based-route pbr1 permit node 0
 if-match acl 3005
 apply next-hop 10.5.1.2
#
policy-based-route pbr1 permit node 1
 if-match acl 3006
 apply next-hop 10.3.1.2
#
interface Vlan-interface2
 ip address 10.1.2.1 255.255.255.0
 ip policy-based-route pbr1
#
interface Vlan-interface3
 ip address 10.3.1.1 255.255.255.0
#
interface Vlan-interface4
 ip address 10.4.1.1 255.255.255.0
#
interface Vlan-interface5
 ip address 10.5.1.1 255.255.255.0
#
ip route-static 192.168.1.0 24 10.3.1.2
 ip route-static 192.168.1.0 24 10.4.1.2 preference 40
 ip route-static 192.168.1.0 24 10.5.1.2
#
acl number 3005
 rule 0 permit ip source 10.2.1.1 0
#
acl number 3006
 rule 0 permit tcp destination-port eq www
#


  • 评论列表

留言评论