route-map的详解和使用(router-map)

网友投稿 1196 2022-09-24


route-map的详解和使用(router-map)

Route-Map:功能性非常强的策略列表,可以用来过滤路由也可以调整路由的属性,自身具备过滤功能。Route-Map的作用:1.在重发布的过程中做route-map,重发布过程中可以改变路由的属性;(次要作用)例如希望在路由被注入RIP后,192.168.1.0路由的metric为1,2.0的metric为2如此这般呢?传统的重发布是没办法做到的。 那么就可以使用route-map这个工具,也就是说,我们可以在执行重发布的时候,关联一个route-map,来实现刚才的这个功能。2.NAT(网络地址转换); (次要作用)3.PBR 策略路由;(次要作用)4.BGP(基于属性的路由选路) ;(主要作用)

应用在重分布,接口( PBR), BGP。Route-map用在重分布中,Route-Map的逻辑语句:利用 ACL 抓取路由条目,Access-list 1 permit 12.1.1.1 0.0.0.0(路由条目)配置 route-maproute-map test permit/deny 10 ( 创建route-map 名字为test 允许或拒绝序号为10match x1(ip address access-list 1)match x2,x3set Yroute-map test permit/deny 20match x4set Y应用 route-map,Router ospf 100 Redistribute rip subnets route-map test

注意:1.Route-Map末尾隐含拒绝所有,所以最后要写允许所有的语句;Route-map test permit 20 代表允许所有。2.如果没有set语句的话,set nothing(什么都不做);3.如果没有match语句的话,match all(匹配所有);4.在重发布过程中使用Route-Map,切记在使用ACL或Prefix-List抓取路由的时候只能使用permit,策略的制定执行由Route-Map完成。

1.Match语句,匹配的作用,自上而下的匹配顺序;匹配动作将会从最小的序列号开始执行,如果该序列号中的条件都被匹配了则执行set命令,如果条件不匹配,则切换到下一个序列号继续进行匹配动作。2.Set语句,执行的作用;set tag 99 打标99set type 1 Set metric1 度量值1set metric-type type-1 (设置OSPF 的开销类型、分为类型1(type-1和类型2(type-2。类型1的计算方法是外部开销(即重发布路由时开销)再加上路由器到ASBR的开销,类型2的计算方法是开销=外部开销。v如下:A---B----C比如C引入一个外部路由到ospf,设定metric为100默认引入的时候是type2的,这样B计算出的花费就是100,A也是100如果设置成type1的,B计算的是100+1=101,A计算的是100+2=102。

定义匹配条件match ip address access-list 1 (prefix-list 1) 匹配访问列表或前缀列表match length 根据分组的第三层长度进行匹配match interface 匹配下一跳出接口为指定接口之一的路由match ip next-hop 匹配下一跳地址为特定访问列表中被允许的那些路由match metric 匹配具有指定度量值的路由match route-type 匹配指定类型的路由match community 匹配BGP共同体match tag 根据路由的标记进行匹配

定义set动作 set metric 设置路由协议的度量值set metric-type 设置目标路由协议的度量值类型set default interface 指定如何发送这样的分组set interface 指定如何发送这样的分组set ip default next-hop指定转发的下一跳set ip next-hop 指定转发的下一跳set next-hop 指定下一跳的地址,指定BGP的下一跳set as-pathset communityset local-preferenceset weightset originset tagdefault 关键字优先级低于明细路由

1.Access-listAccess-lsit 1 permit/deny 12.1.1.0Router ospf 1Distribute-list 1

2.Prefix-listip prefix-list test permit/deny 12.1.1.0 255.255.255.0Route-map test permit 10Match ip address prefix-list test

3.Metric(RIP和OSPF间路由重发布)Route-map rip2ospf permit 10Match metric 6Router ospf 1Redistribute rip subnets route-map rip2ospf

4.metric(rip和ospf间路由重发布)Route-map ospf2rip permit 10Match metric 101Router ripredistribute ospf route-map ospf2rip metric 1

5.metric(bgp和ospf间路由重发布)Route-map bgp2ospf1 permit 10Match metric 200Router-map bgp2ospf2 permit 10Match metric 100Router ospf 1Redistribute bgp 1 subnets route-map bgp2ospf1Router ospf 2Redistribute bgp 1 subnets route-map bgp2ospf2

6.tag 就是在重发布时给路由打标签redistribute rip subnet tag 1意味着把rip重发布进入ospf,然后给所有重发布的rip路由打上tag 为 1 ,做个标记,方便在做策略时整个调用(在抓路由时可以规定抓取所有tag=1 的路由)Redistribute bgp 1 subnets tag 10

R1(config)#interface e 0/1ip address 12.1.1.1 255.255.255.0no shutdowninterface lo 0ip address 1.1.0.1 255.255.255.0interface lo 1ip address 1.1.1.1 255.255.255.0interface lo 2ip address 1.1.2.1 255.255.255.0interface lo 3ip address 1.1.3.1 255.255.255.0router ripversion 2network 12.1.1.0network 1.1.0.0network 1.1.1.0network 1.1.2.0network 1.1.3.0no auto-summaryR2(config)#interface e 0/1ip address 12.1.1.2 255.255.255.0no shutdowninterface e 0/3ip address 23.1.1.2 255.255.255.0no shutdownrouter rip version 2network 12.1.1.0no auto-summaryinterface e 0/3router ospf 100router-id 2.2.2.2network 23.1.1.0 0.0.0.255 area 1R3(config)#interface e 0/3ip address 23.1.1.3 255.255.255.0no shutdownrouter ospf 100router-id 3.3.3.3network 23.1.1.0 0.0.0.255 area 1

现在通过在R2 重发布把RIP 信息发布到OSPF 里面、并且调用 route-map定制的好的控制列表、使得R3 有规则的仿问R1 。R2(config)#1.抓取路由条目:ip prefix-list permit0 permit 1.1.0.0/24命名为permit0前缀列表允许1.1.0.0/24网段通过ip prefix-list permit1 permit 1.1.1.0/24ip prefix-list permit2 permit 1.1.2.0/24ip prefix-list permit3 permit 1.1.3.0/24access-list 1 permit 12.1.1.0 0.0.0.255访问控制列表1 允许12.1.1.0网段通过2.制定Route-Map:route-map rip2ospf deny 10( 创建route-map 名字为rip2ospf 拒绝 序号为10match ip address prefix-list permit0(匹配 permit0名的前缀列表route-map rip2ospf permit 20match ip address prefix-list permit1set metric-type type-1(设置OSPF 的开销类型为类型1route-map rip2ospf permit 30match ip address prefix-list permit2set metric 200(设置度量值200route-map rip2ospf permit 40match ip address prefix-list permit3set tag 333(打标333 route-map rip2ospf permit 50match ip address 1set tag 111

3.重发布过程中调用Route-Map:exitrouter ospf 100redistribute rip subnets route-map rip2ospf(把rip重发布到ospf中、发布过程中调用Route-Map

查看R3 路由表。 show ip route show ip route ospf show ip ospf database


版权声明:本文内容由网络用户投稿,版权归原作者所有,本站不拥有其著作权,亦不承担相应法律责任。如果您发现本站中有涉嫌抄袭或描述失实的内容,请联系我们jiasou666@gmail.com 处理,核实后本网站将在24小时内删除侵权内容。

上一篇:Java 17 随机数生成器来了一波稳稳的增强
下一篇:标准ACL和扩展ACL(标准acl和扩展acl分别应用在什么环境)
相关文章

 发表评论

暂时没有评论,来抢沙发吧~