目录 ip prefix-list命令详解 route-map ip prefix-list命令详解 Construct a prefix list that permits only the 192.168.1.0 <Route-Map> 也叫路由图或者路由映射表,是对路由进行加工处理的工具。 1、route-map可以调用ACL或prefix抓出一部分路由进行加工处理 2、每一个route-map可以有多条语句,每条语句都有一个序号 3、每条语句都有两种动作:match 和 set 4、每条语句对抓出来的路由都有两种处理方式 :permit 或 deny route-map的使用分三步操作: 1、定义ACL或prefix抓出路由(定义感兴趣流量) 2、定义route-map说明对匹配的路由所采取的处理方式 3、调用route-map //route-map只是一个策略的工具,不调用是没有作用的. route-map的匹配逻辑: route-map NAME permit 10 match ip address x y z ——->
Route-map 什么是route-map, 怎么说呢?你说它属于什么呢?属于路由策略?还是属于策略路由? Distribute,redistribute,等等,都能看到它的身影 初识route-map 1、Route-map中的语句相当于acl的各行 2、route-map的序列号默认为10,不会自动递增 Route-map的运行方式 PS:在route-map中,和ACL是一样的,最后都有一条deny 的动作, 所以,我们在部署route-map时,也要分情况的来配置一条permit 当然,是分情况哦 Distribute-list + acl,是ACL起到决策作用(deny/permit) Route-map+ ACL 是route-map起到了决策作用,(所以通常使用route-map时,ACL都是 ospf 1 route-map ospf //重分布时调用route-map 最后再来看一下R1上的变化吧 一个变成了2跳,一个变成了5跳,成功 再来看另外一侧,RIP注入OSPF后显示不同
R3-R4路径 访问4.4.4.4时走R1-R2-R4路径 R4访问R1: 访问1.1.1.1时走R4-R3-R1路径 访问1.1.1.2时走R4-R2-R1路径 二、关键配置技术点 路由映射(Route-Map OSPF与BGP联动: 使用环回口建立iBGP邻居 三、四大厂商配置对比(BGP路由策略) 配置项 思科(Cisco) 华为(Huawei) 华三(H3C) 锐捷(Ruijie) 路由映射创建 route-map address-family ipv4 neighbor 12.1.1.2 activate neighbor 12.1.1.2 route-map FROM_R2_IN in neighbor 13.1.1.3 activate neighbor 13.1.1.3 route-map FROM_R3_IN in route-map FROM_R2_IN permit 10 match R4配置(锐捷) router bgp 200 neighbor 2.2.2.2 route-map FROM_R2_IN in neighbor 3.3.3.3 route-map FROM_R3
r1(config)#access-list 1 permit 2.2.2.0 0.0.0.255 /用ACL匹配该路由 r1(config)#route-map WY permit 10 r1(config-route-map )#match ip add 1 r1(config-route-map)#set community no-advertise /设定团体属性 r1(config)#route-map WY permit 20 /与ACL一样 route-map最后也隐藏了一句deny any ,所以在这里要允许所有,要不然其它两条路由会因为匹配不上而无法从R1传递出去。 r1(config)#router bgp 100 r1(config-router)#neighbor 12.0.0.2 route-map WY out /在进程下出方向调用route-map r1 )#router bgp 64513 r4(config-router)#neighbor 34.0.0.3 route-map WY in 指定R3向R4传递路由时应用该route-map,所以是in
distribute-list 与 route-map 相同点: 都可以用来做路由过滤 不同点: 1)distribute-list 只能过滤路由条目,无法修改路由属性;route-map除了可以过滤路由条目 2)route-map可以强制修改数据包的下一跳,做策略路由。 4)route-map应用的地方为:路由协议重分发时,bgp邻居传递路由时。 如何选择: 看具体的应用场景,若distribute-list 与route-map均能够使用,那么若需要修改路由属性,必须使用route-map;若不需要修改路由属性,2者选其一就可以。
默认deny any 可以调用acl和ip prefix-list,调用的acl和prefix-list中的permit代表匹配,deny代表不匹配而不是允许和拒绝,真正的permit和deny是在route-map A permit/deny exp1: route-map FL permit match ip address prefix-list 13(ip prefix-list 13 permit 10.0.0.0/13 ge 16 le 16) 完全抓取了prelist13的条目,其他的路由不抓取 exp2: route-map DMV** permit match ip address prefix-list 6 (ip prefix-list 6 permit 10.6.0.0/16) set local-prefanence 99 route-map DMV** permit 20 写了permit 20,意为只对prefix-list 6 设置LP 99,其他路由不做修改(一般使用set参数的时候需要route-map X permit 20) session 2
所以这里要使用到route-map针对源地址和出端口进行筛选。而判断出端口的任务,就交由带track的浮动静态路由实现。 TO_R3_NAT interface e0/2 overload ip nat inside source route-map TO_R4_NAT interface e0/3 overload ip TO_R3_NAT permit 10 match ip address VLAN_12 VLAN_21 match interface e0/2 route-map TO_R4_NAT TO_R3_NAT interface e0/2 overload ip nat inside source route-map TO_R4_NAT interface e0/3 overload TO_R3_NAT permit 10 match ip address VLAN_12 VLAN_21 match interface e0/2 route-map TO_R4_NAT permit
route-map 应用route-map设置路由属性。 map-name route-map的名字。 route-map以名字标识,同一个route-map下可以有多个条目。系统中route-map的总数仅受系统的资源限制。同一route-map下的各条目都可以指定序号或系统自动生成序号。 ip policy route-map route-map name no ip policy route-map route-map name 参数 参数 参数说明 route-map name route-map route-map route-map route-map name [sequence-number] [permit | deny] no route-map route-map name[sequence-number 使用说明 使用route-map命令配置route-map。 示例 例:下列例子配置了一个名叫pbr的route-map。
0 23 1 i 修改local_preference改变选路 R4: R4(config)#ip prefix-list 1 per 1.1.1.0/24 R4(config)#route-map R4(config-route-map)#set local-preference 200 R4(config)#router bgp 4 R4(config-router)#nei 34.1.1.3 route-map 过来路由的weight,来比较weight和local-preference的优先级 R4: R4(config)#ip prefix-list 2 per 1.1.1.0/24 R4(config)#route-map prefix-list 2 R4(config-route-map)#set weight 100 R4(config)#router bgp 4 R4(config-router)#nei 24.1.1.2 route-map
auto-summary exit-address-family 查看 BGP邻居关系表: 查看路由表: R4: access-list 1 permit 12.1.1.0 0.0.0.255 route-map ccie permit 10 match ip address 1 router eigrp 100 redistribute bgp 200 metric 10000 100 255 1 1500 route-map discarded: 0 Connection and counters cleared 00:22:21 ago SA Filtering: Input (S,G) filter: none, route-map : none Input RP filter: none, route-map: none Output (S,G) filter: none, route-map: none Output RP filter: none, route-map: none SA-Requests: Input filter: none Peer ttl threshold: 0 SAs learned
RIP 120 OSPF 110 EIGRP 90或170 注意:可以针对具体路由进行更改 2.2过滤工具 2.2.1 标记工具TAG:将路由进行标识,针对标记进行匹配 一般情况只能是route-map 2.2.4 route-map 2.2.4.1 用于复杂性匹配 2.2.4.2 可用于改变各种属性 2.2.4.3 可以调用其他过滤工具 :在调用其他过滤工具时 语句直接忽略 2.2.5 distribute-list 2.2.5.1 2.2.6fliter-list 3.策略路由 3.1在不改变路由表的情况下,通过route-map
如果想有条件地宣告默认路由,后面可以加挂route-map。譬如某个接口是Up的,或是某条前缀是有效的。 先匹配要过滤掉的路由前缀,使用prefix list和route-map。 OSPF进程下下发列表在in方向调用route-map。 全局路由表的路由被干掉了,但是LSDB的3类LSA还在。 # 重分布时挂route-map R13(config-router)#redistribute bgp 10 subnets route-map ? WORD Pointer to route-map entries # OSPF进程下使用distribute-list,它再调用ACL,Prefix-List和Route-Map。 Filter prefixes based on the route-map 具体的ACL,Prefix-List和Route-Map和上面大同小异。
使用route-map及策略路由可以根据数据包的特征修改其相关QoS项,进行为QoS服务。 负载平衡。 match ip address 1 关联acl 1 的ip地址 set ip next-hop 192.168.2.2 符合上面acl中的ip地址经过这个路由器之后下一跳的ip地址为192.168.2.2 route-map 创建路由表并命名标上编号 match ip address 111 关联acl111 set ip next-hop 192.168.2.6 目的地址符合acl 111 的数据流下一跳为192.168.2.6 route-map match ip address 112 set ip next-hop 192.168.3.6 目的地址符合acl 112 的数据流下一跳为192.168.3.6 1.4.3 基于报文长度的策略路由 route-map 创建路由表并命名,标上序号 match length 0 100 表示报文大小在0-100之内的数据流 set ip next-hop 192.168.1.1 下一跳的ip地址为192.168.1.1 route-map
NLRI O NT 16 extended communities Filter Sequence : IN : 1 prefix-list 2 filter-list 3 weight 4 route-map OUT: 1 prefix-list 2 filter-list 3 router-map IGP: 1 distribute-list 2 route-map (redistribution)
bestpath attribute entries using 416 bytes of memory1 BGP AS-PATH entries using 24 bytes of memory0 BGP route-map remote-as 111 neighbor 11.11.11.1 activate neighbor 11.11.11.1 prefix-list MYIP out neighbor 11.11.11.1 route-map remote-as 111 neighbor 10.10.10.1 activate neighbor 10.10.10.1 prefix-list MYIP out neighbor 10.10.10.1 route-map
1)定义 ACL感兴趣流 ip access-listextended 100 10 permit ip 10.0.0.0 0.255.255.255 any 2)定义策略路由 route-map 3)接口应用策略路由 interfaceGigabitEthernet 3/1/0 ip policy route-map internet 二、大型案例 2.1 实际组网需求 政务网中 PE1配置: 1、基本路由连通性配置: ip vrf V**1 interface GigabitEthernet 3/1/0 ip policy route-map internet extended 100 10 permit ip 10.0.0.0 ip ac0.255.255.255 any interfaceGigabitEthernet 3/1/0 ip policy route-map
10.112.1.0 24 bgp 2300 ipv4 family unicast peer 10.12.1.1 ip-prefix deny_10 import 第二种方法:配置前缀列表,但是结合Route-map 例如:将 OSPF 路由重分发到 BGP 中,但是不收取 10.112.1.0/24 这条路由,则它的配置命令如下: Cisco ip-prefix deny_10 10.112.1.0/24 route-map deny_10 match ip address prefix deny_10 router bgp 2300 address-family ipv4 redistribute ospf 2300 route-map community-list standard DENY_300:3 deny 300:3 //配置针对标准 Community 的 Community List ,名称为 DENY_300:3 ,拒绝的标记是 300:3 route-map /配置 Route map ,包含 Community List 为 DENY_300:3 router bgp 200 address-family ipv4 neighbor 10.23.1.2 route-map
配置路由映射和Community设置: route-map <map-name> permit <sequence-number> match <match-criteria> set community 将路由映射应用到BGP邻居: neighbor <neighbor-ip> route-map <map-name> in|out 使用in参数将路由映射应用于入站路由,使用out参数将路由映射应用于出站路由 配置路由映射和Community设置: route-map <map-name> permit <sequence-number> match <match-criteria> set community 将路由映射应用到BGP邻居: neighbor <neighbor-ip> route-map <map-name> in|out 使用in参数将路由映射应用于入站路由,使用out参数将路由映射应用于出站路由
10.1.0.0/16 ge 17 le 24 前面表示多少位要严格匹配,后面的ge le表示掩码的范围 这句话的意思是:匹配一10.1开头的,掩码Wie17位到24位的所有路由条目 route-map 作用对象 接口上配置了PBR,只能对进入的流量生效 全局下配置PBR,只能对本地产生的流量生效(需要加上:ip local policy route-map map-name) show ip 使用IPV4传递IPV6路由会导致IPV6路由的下一跳不可达,需要使用route-map不可达 123下发默认路由 124学习明细 125全局NAT crypto ipsec nat-transparency 只有通告出去的时候才会加自己的接口cost show ip bgp rib-failure 可以查看加表失败的BGP路由的原因 使用IPv4承载IPv6路由,会使得IPv6的路由的下一跳不可达,需要使用route-map
配置路由映射和Community设置:route-map <map-name> permit <sequence-number>match <match-criteria>set community < 将路由映射应用到BGP邻居:neighbor <neighbor-ip> route-map <map-name> in|out使用in参数将路由映射应用于入站路由,使用out参数将路由映射应用于出站路由 配置路由映射和Community设置:route-map <map-name> permit <sequence-number>match <match-criteria>set community < 将路由映射应用到BGP邻居:neighbor <neighbor-ip> route-map <map-name> in|out使用in参数将路由映射应用于入站路由,使用out参数将路由映射应用于出站路由