华为策略路由route-policy

route-policy 工具的使用【可以匹配外来的流量】在R2配置可以影响R1的流量走向


一、route-policy

 AR1配置

AR1
#
interface GigabitEthernet0/0/0            //配置接口地址
 ip address 12.1.1.1 255.255.255.0 
#
#
interface LoopBack0                        //配置环回地址1和2
 ip address 1.1.1.1 255.255.255.255 
#
interface LoopBack1
 ip address 11.11.11.11 255.255.255.255 
#
#
ospf 1                                     //配置ospf 1 
 import-route direct                        //将直连接口引入(loopback 1 和 loopback 2)
 area 0.0.0.0 
  network 12.1.1.0 0.0.0.255 
#
 

AR2

#                    //匹配相对的流量
acl number 2000  
 rule 5 permit source 1.1.1.1 0    //精确匹配1.1.1.1
acl number 2001  
 rule 5 permit source 11.11.11.11 0     //精确匹配11.11.11.11
#
#
traffic classifier 2         //配置流分类 2
 if-match acl 2001           //匹配acl 2001
traffic classifier 1         //配置流分类1
 if-match acl 2000            //匹配acl 2000
#
#
traffic behavior 2                //配置流行为2
 redirect ip-nexthop 24.1.1.4    //重定向下一跳为24.1.1.4
traffic behavior 1                //配置流行为1
 redirect ip-nexthop 23.1.1.3     //重定向下一跳为23.1.1.3
#
#
traffic policy 1                    //配置路由策略 1
 classifier 1 behavior 1            //classifier 1绑定流分类 1  behavior 1绑定流行为也为1
 classifier 2 behavior 2
#
#
interface GigabitEthernet0/0/0
 ip address 12.1.1.2 255.255.255.0 
 traffic-policy 1 inbound            //在入接口调用路由策略 1 入口

AR3
#
interface GigabitEthernet0/0/0
 ip address 23.1.1.3 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 35.1.1.3 255.255.255.0 
#
#
ospf 1 router-id 3.3.3.3 
 area 0.0.0.0 
  network 23.1.1.0 0.0.0.255 
  network 35.1.1.0 0.0.0.255 
#

AR4


interface GigabitEthernet0/0/0
 ip address 24.1.1.4 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 45.1.1.4 255.255.255.0 
#
ospf 1 router-id 4.4.4.4 
 area 0.0.0.0 
  network 24.1.1.0 0.0.0.255 
  network 45.1.1.0 0.0.0.255 
#

AR5

#
interface GigabitEthernet0/0/0
 ip address 45.1.1.5 255.255.255.0 
#
interface GigabitEthernet0/0/1
 ip address 35.1.1.5 255.255.255.0 
#
#
interface LoopBack0                        //配置loopback 0  用于测试ar1到ar5的选路
 ip address 5.5.5.5 255.255.255.255 
#
ospf 1 router-id 5.5.5.5 
 import-route direct                        //引入5.5.5.5网段信息
 area 0.0.0.0 
  network 35.1.1.0 0.0.0.255 
  network 45.1.1.0 0.0.0.255 
#


二、PBR(Policy-Based Routing)

通过策略路由PBR将自己产生的路由自定向【只能匹配自身流量】

在利用ospf在R2去往5.5.5.5的流量上达到负载均衡

让2.2.2.2的流量去g0/0/1口   让22.22.22.22 的流量去g0/0/2口

#
interface LoopBack0
 ip address 2.2.2.2 255.255.255.255 
#
interface LoopBack1
 ip address 22.22.22.22 255.255.255.255 
#

#
acl number 2000              //ACL抓取对应的路由信息
 rule 5 permit source 2.2.2.2 0 
 rule 10 deny 
acl number 2001  
 rule 5 permit source 22.22.22.22 0 
 rule 10 deny 
#

#
policy-based-route 1 permit node 10        //配置策略路由 
 if-match acl 2000                        //绑定acl 2000的流量
 apply output-interface GigabitEthernet0/0/1  //匹配的路由信息强制下一跳出口为g0/0/1口
policy-based-route 1 permit node 20
 if-match acl 2001
 apply output-interface GigabitEthernet0/0/2  
#

ip local policy-based-route 1   //全局模式下使能pbr1

  • 1
    点赞
  • 32
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

li工

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值