策略控制
抓取流量:ACL, prefix-list
路由控制:distribute-list 、route-map、offset-list
1 控制路由信息(抓取感兴趣路由信息)
ACL:缺点:1.不能精确抓取网络掩码 2.不能范围性抓取路由信息
prefix-list:前缀列表,只能抓取路由信息
R2(config)# ip prefix-list ccna permit 1.1.1.0/24 ge 26 le 28
//ccna为前缀列表的名字,24代表掩码长度
//该列表为允许掩码26 27 28的路由通过
ge:大于等于 le :小于等于 le大于等于ge大于length
R2(config)# ip prefix-list ccna permit 2.2.2.0/24
//允许2.2.2.0/24
R2(config)# ip prefix-list ccna permit 2.2.2.0/24 ge 28
//允许2.2.2.0掩码范围在28到32之间的
R2(config)# ip prefix-list ccna permit 2.2.2.0/24 le 30
//允许2.2.2.0掩码范围在24到30之间的
R2(config)# ip prefix-list ccna permit 2.2.2.0/24 ge 28 le 28
//允许2.2.2.0掩码固定为28
R2(config)# ip prefix-list ccna permit 0.0.0.0/0 ge32
//匹配所有主机路由
R2(config)# ip prefix-list ccna permit 0.0.0.0/0
//匹配默认路由
R2(config)# ip prefix-list ccna permit 0.0.0.0/0 le32
//允许所有
2 distribute-list:分发列表,发布列表
作用:过滤路由信息,distribute-list自身不具备过滤功能,必须借助ACL或prefix-list
a 在DV协议中,在in或者out方向过滤
b 在LS协议中,仅仅在in方向上实施,并且不能过滤LSA,仅仅阻止该路由加表
c 在重发布过程中(将A协议重发布进入B协议时),进入B协议,使用out+A
在DV协议:
-----调用
R3(config)# router rip
R3(config-router)# distribute-list prefix ccie out s2/1
在重发布过程中进行过滤:
—调用
R2(config)# router ospf 100
R2(config)# distribute-list prefix ccnp out rip
3 router-map
使用位置:a.重发布 b.PBR(QOS) c.BGP
特点:
a 自身具备过滤功能
b match set
c 末尾隐含拒绝所有
d match set 写法
(横向match,match any、 竖向match,match all)
eg:::
R1(config)#route-map ccie deny 10 //创建一个router-map ccie 10序号
R1(config-route-map)#match ip address prefix-list ccnp //匹配prefix ccnp
R1(config-route-map)#exit
R1(config)#route-map ccie permit 20
R1(config-route-map)#match ip address prefix-list ccna
R1(config-route-map)#set metric 99 //设置匹配的度量值为99
R1(config-route-map)#exit
R1(config)#route-map ccie permit 30
R1(config-route-map)#match ip address 1 //匹配acl 1 的路由
R1(config-route-map)#set metric-type type-1 //修改ospf的类型为1
R1(config-route-map)#exit
R1(config)#route-map ccie permit 40 //允许所有
注:使用router-map要配合acl或者prefix-list使用,抓取流量
4 PBR :policy based router 基于策略路由(与路由无关)
R1(config)#route-map ccie permit 10
R1(config-route-map)#match ip address 10 //匹配流量
R1(config-route-map)#set ip next-hop 23.1.1.2 //指定下一跳为23.1.1.2
R1(config-route-map)#exit
R1(config)#route-map ccie permit 20 //允许所有
在数据进向接口调用
R2(config)# interface s2/0
R2(config-if)# ip policy route-map ccie
针对本设备自己产生的流量不能使用正常PBR,必须使用本地PBR
全局模式调用:
R2(config)# ip local policy route-map ccnp
-------本文纯属自己所作,因能力有限,如有不足之处,还请指出,谢谢!