cisco 路由策略:Route-map

2025-10-26 14:47:45

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

1、使用match命令匹配特定的分组或路由,set修改该分组或路由相关属性。

Route-map中的语句相当于访问列表中的各行。

Route-map默认为permit,默认序列号为10,序号不会自动递增,需要指定序列号

末尾隐含deny any

单条match语句包括多个条件时,使用逻辑or运算;多条match语句时,使用逻辑and运算。

1、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的下一跳

cisco 路由策略:Route-map

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

cisco 路由策略:Route-map

2、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 值

3、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

!

!

4、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

5、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

!        

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
猜你喜欢