cisco 路由策略:Route-map

作者:流年 | 创建时间: 2023-06-22
路由策略主要用于管理重发布的时候的路由,如果重发布有多条路径到达同一目的地的时候方可使用路由策略来管理路由的metic值,以meitc值来选路。...
cisco 路由策略:Route-map

Route-map

逐级向下比对匹配每一个match语句,如果匹配,则执行SET动作,否则进入下一个条目。

Route-map的特点

使用match命令匹配特定的分组或路由,set修改该分组或路由相关属性。 Route-map中的语句相当于访问列表中的各行。 Route-map默认为permit,默认序列号为10,序号不会自动递增,需要指定序列号 末尾隐含deny any 单条match语句包括多个条件时,使用逻辑or运算;多条match语句时,使用逻辑and运算。

Route-map的配置

Match   ip address 匹配访问列表或前缀列表 Match   ip length 根据分组的第三层长度进行匹配 Match   interface 匹配器下一跳为指定接口之一的路由 Match   ip next-hop 匹配器下一跳路由器地址获得防伪列表之一允许的路由 Match   metric 匹配具有指定度量值的路由 Match   route-type 匹配指定类型的路由 Match   community 匹配BGP共同体 Match   tag 根据路由的标记进行匹配 Route-map(cont) Set   metric 设置路由协议的度量值 Set   metric-type 设置目标路由协议的值类型 Set   default interface 指定如何发送这样的分组 Set   interface 指定如何发送这样的分组 Set ip   default next-hop 指定转发的下一跳 Set ip   next-hop 指定转发的下一跳 Set   next-hop 指定下一跳的地址,指定BGP的下一跳

MAP实验

R2上有两个loopback口,当R4ping 192.168.1.1的时候往R1走,当R4ping 192.168.2.1的时候往R3走;两条链路相互冗余。

R1: interface Serial0/0 ip address 1.1.1.1 255.255.255.0 ! interface Serial0/1 ip address 4.4.4.2 255.255.255.0 ! router ospf 1 log-adjacency-changes redistribute static subnets route-map cisco          !--重发布静态地址,使用route-map network 4.4.4.0 0.0.0.255 area 0 ! ip classless ip route 192.168.1.0 255.255.255.0 1.1.1.2 ip route 192.168.2.0 255.255.255.0 1.1.1.2 ! access-list 1 permit 192.168.1.0 access-list 2 permit 192.168.2.0 no cdp log mismatch duplex ! route-map cisco permit 10         !--配置route-map name=cisco 优先级为10 ,越小越高 match ip address 1                      !--匹配access-list set metric 1                                  !--设置metric 值 ! route-map cisco permit 20         !--此条的意思是设置第二条 ,优先级为20 match ip address 2                      !--匹配access-list set metric 2                                   !--设置metric 值

R2: interface Loopback0 ip address 192.168.1.1 255.255.255.0 ! interface Loopback1 ip address 192.168.2.1 255.255.255.0 ! interface Serial0/0 ip address 1.1.1.2 255.255.255.0 ! interface Serial0/1 ip address 2.2.2.1 255.255.255.0 ! ip classless ip route 3.3.3.0 255.255.255.0 2.2.2.2 ip route 3.3.3.0 255.255.255.0 1.1.1.1 2 ip route 4.4.4.0 255.255.255.0 1.1.1.1 ip route 4.4.4.0 255.255.255.0 2.2.2.2 2 ! !

R3: ! interface Serial0/0 ip address 2.2.2.2 255.255.255.0 ! interface Serial0/1 ip address 3.3.3.1 255.255.255.0 ! router ospf 1 log-adjacency-changes redistribute connected subnets redistribute static subnets route-map cisco network 3.3.3.0 0.0.0.255 area 0 ! ip classless ip route 192.168.1.0 255.255.255.0 2.2.2.1 ip route 192.168.2.0 255.255.255.0 2.2.2.1 ! access-list 1 permit 192.168.1.0 access-list 2 permit 192.168.2.0 no cdp log mismatch duplex ! route-map cisco permit 10 match ip address 2 set metric 1 ! route-map cisco permit 20 match ip address 1 set metric 2

R4: ! interface Serial0/0 ip address 4.4.4.1 255.255.255.0 ! interface Serial0/1 ip address 3.3.3.2 255.255.255.0 ! router ospf 1 log-adjacency-changes network 3.3.3.0 0.0.0.255 area 0 network 4.4.4.0 0.0.0.255 area 0 network 192.168.10.0 0.0.0.255 area 0 !

温馨提示

感谢你浏览(12黄奇锋)的经验,如果经验对您有帮助请为我“投票”,为经验献爱心让更多人知道请“转发”,怕找不到此经验请进行“收藏”。想了解最新动态请“关注我”。
点击展开全文

更多推荐