PBR实验
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/e7b87d7dafe64084bd476dab18b0f663.png)
- 策略路由是基于策略实现数据流量转发,不基于路由表。
lsw: 配置三层交换机
vlan batch 10 20 30
int g0/0/2
port link-type access
port default vlan 10
int g0/0/3
port link-type access
port default vlan 20
int g0/0/1
port link-type access
port default vlan 30
int vlanif 10
ip add 192.168.10.254 24
int vlanif 20
ip add 192.168.20.254 24
int vlanif 30
ip add 192.168.10.1 24
ospf
a 0
net 0.0.0.0 0.0.0.0
int g0/0/0
ip add xx
ospf router-id 1.1.1.1
a 0
net 0.0.0.0 0.0.0.0
dis ip routing-table
int g0/0/1
ospf cost 100
dis ip routing-table
acl 3000
rule 5 permit ip source 192.168.20.0. 0.0.0.255 destination 8.8.8.8 0 # 此时需要抓取所有流量,所以使用ip
traffic classifier 20.0 operator or # 定义一个流分类, or 是匹配一个, and是全部匹配 if-match
if-match acl 3000
traffic behavior AR3 # 定义一个流行为
redirect ip-nexthop 13.1.1.3 # 华为中没法走interface
traffic policy PBR # 定义一个流策略,将流分类和流行为匹配起来,同时在接口出调用
classifier 20.0 behavior AR3
int xx
traffic-policy AR3 inbound # 进入该接口的流量会使用PBR进行过滤,匹配上的流量将执行流行为,未匹配的流量将正常通过
注释:被接口PBR匹配到的流量将执行PBR策略路由进行转发,没有匹配到的流量在进入路由器后正常通过路由表进行转发。
int loopback 0
ip add 1.1.1.1 32
acl 2000
rule 5 permit source 1.1.1.1 0 # 抓取源
policy-based-route PBR-2 permit node 10 # 配置本地路由策略
if-match acl 2000
apply ip-address next-hop 13.1.1.3
ip local policy-based-route PBR-2 # 在R1上开启本地策略路由
nqa test-instance admin icmp # nqa一个测试实例, admin为管理员的名称,icmp为实例的名称
test-type icmp # 通过ping去探测
frequency 5 # 5s中一次
destination-address ipv4 13.1.1.3 # 探测的目的地址
source-address g0/0/2 # 探测的源地址的或者接口
start now # 开启探测,类似bfd中commit
traffic behavior AR3
redirect ip-nexthop 13.1.1.3 track nqa admin icmp # 将路由行为与nqa进行联动
display nqa results test-instance admin icmp # 查看nqa探测的结果,success 或者 failed (completion
环路解决
![在这里插入图片描述](https://img-blog.csdnimg.cn/direct/0a79b91b472b4d1c932290d9dbc90df2.png)
import-route { limit xx| { direct | unr | rip xx| static | ospf xx } [ cost xx | type xx | tag xx | route-policy xx ] * }
// 首先按照要求实现网络互联: 在R1上将静态路由引入ospf中, 以R1为例
ospf 1
import-route static
ospf 1
area 0
net 12.1.1.1 0.0.0.0
int loopback 0
ip add 1.1.1.1
ospf network-type broadcast // 将接口加入ospf中
ospf enable 1 area 0
// isis, 以R2为例
isis
network-entity 49.00001.0000.0000.00001.00
int g0/0/2
isis enable
// 完成基本网络拓扑后,在R2上tracert 192.168.10.1 出现环路!!!
- 问题: 完成基本网络拓扑后,在R2上tracert 192.168.10.1 出现环路!!!
- 解决办法:
- 方法1: 通过修改ospf的ase preference < isis的preference 15, 即让ospf学到的加表
- 方法2: 使用PBR策略路由,但是维护困难
- 方法3: 让isis学到的路由不加表
// 方法1: R2上修改ase pre
ospf
ase preference 10
dis ip routing-table
// 方法3:R2上让isis学到的路由不加表
acl 2000
rule deny source 192.168.10.0 0
rule deny source 192.168.20.0 0
rule permit source any
isis 1
filter-policy 2000 import