cisco 路由策略:Route-map
来源:网络收集 点击: 时间:2024-08-24逐级向下比对匹配每一个match语句,如果匹配,则执行SET动作,否则进入下一个条目。
Route-map的特点1/1使用match命令匹配特定的分组或路由,set修改该分组或路由相关属性。
Route-map中的语句相当于访问列表中的各行。
Route-map默认为permit,默认序列号为10,序号不会自动递增,需要指定序列号
末尾隐含deny any
单条match语句包括多个条件时,使用逻辑or运算;多条match语句时,使用逻辑and运算。
Route-map的配置1/1Match 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的下一跳

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 值
3/5R2:
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/5R3:
!
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/5R4:
!
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黄奇锋)的经验,如果经验对您有帮助请为我“投票”,为经验献爱心让更多人知道请“转发”,怕找不到此经验请进行“收藏”。想了解最新动态请“关注我”。
路由器CISCOGNS3ROUTE-MAP版权声明:
1、本文系转载,版权归原作者所有,旨在传递信息,不代表看本站的观点和立场。
2、本站仅提供信息发布平台,不承担相关法律责任。
3、若侵犯您的版权或隐私,请联系本站管理员删除。
4、文章链接:http://www.1haoku.cn/art_1155207.html