赞
踩
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
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。