Route Map
2025/10/29大约 3 分钟
Route Map
Route Map 一种强大的工具,可以根据特定条件对动态路由协议进行操作。主要用于 BGP,用于操作由 FortiGate 宣告的路由(route-map-out)或从其他路由器接收的路由(route-map-in)。
在 OSPF 中,可以使用 Route Map 进行条件性的 default-information-originate(宣告默认路由)、过滤邻居宣告的路由,或者匹配特定路由进行重分发。Route Map 也可以被 RIP 使用来匹配重分发的路由。
一个 Route Map 可以包含多个规则,按照自上而下的顺序进行处理。每个规则都有允许或拒绝的动作。这些规则根据各种属性匹配路由,并根据匹配的路由设置路由相关属性,最后的隐含动作为 deny any。
例如可以使用 Route Map 来匹配特定 Community 的 BGP 路由,然后设置匹配路由的 AS Path。然后在 BGP 邻居的设置中应用此 Route Map。
配置方法
config router route-map
edit <name>
config rule
edit <id>
set action {permit | deny}
set match-as-path <string>
set match-community <string>
set match-ip-address <string>
set match-ip6-address <string>
set match-ip-nexthop <string>
set match-ip6-nexthop <string>
next
end
next
endmatch-as-path <string>:匹配一个 BGP AS Path List。match-community <string>:匹配一个 BGP Community。match-ip-address <string>:匹配一个 access-list 或 prefix-list。match-ip6-address <string>:匹配一个 access-list6 或 prefix-list6。match-ip-nexthop <string>:匹配 IPv4 路由的下一跳,通过 access-list 或 prefix-list 表示。match-ip6-nexthop <string>:匹配 IPv6 路由的下一跳,通过 access-list6 或 prefix-list6 表示。
引用 Route Map
被 RIP 引用
config router rip
config redistribute
edit <name>
set routemap <string>
next
end
end被 OSPF 引用
config router ospf
set default-information-route-map <string>
set distribute-route-map-in <string>
config redistribute <string>
set routemap <string>
end
enddefault-information-route-map <string>:根据 Route Map 中匹配的路由是否存在于路由表,决定是否宣告默认路由。distribute-route-map-in <string>:入方向根据引用的 Route Map 操作路由。redistribute <string>:在重发布中引用 Route Map 过滤路由。
被 BGP 引用
config router bgp
config neighbor
edit <ip>
set route-map-in <string>
set route-map-in6 <string>
set route-map-in-vpnv4 <string>
set route-map-out <string>
set route-map-out-preferable <string>
set route-map-out6 <string>
set route-map-out6-preferable <string>
set route-map-out-vpnv4 <string>
set route-map-out-vpnv4-preferable <string>
next
end
config network
edit <id>
set prefix <IP/netmask>
set route-map <string>
next
end
config redistribute <string>
set route-map <string>
end
endroute-map-in <string>:在入方向引用 Route Map 操作 IPv4 路由。route-map-in6 <string>:在入方向引用 Route Map 操作 IPv6 路由。route-map-in-vpnv4 <string>:在入方向引用 Route Map 操作 VPNv4 路由。route-map-out <string>:在出方向引用 Route Map 操作 IPv4 路由。route-map-out-preferable <string>:在 SD-WAN Neighbor 中满足 SLA 标准的 BGP 邻居使用的出方向 Route Map,针对 IPv4 路由(不满足 SLA 标准的 BGP 路由使用普通的 route-map-out)。route-map-out6 <string>:在出方向引用 Route Map 操作 IPv6 路由。route-map-out6-preferable <string>:在 SD-WAN Neighbor 中满足 SLA 标准的邻居使用的出方向 Route Map,针对 IPv6 路由(不满足 SLA 标准的 BGP 路由使用普通的 route-map-out6)。route-map-out-vpnv4 <string>:在出方向引用 Route Map 操作 VPNv4 路由。route-map-out-vpnv4-preferable <string>:在 SD-WAN Neighbor 中满足 SLA 标准的 BGP 邻居使用的出方向 Route Map,针对 VPNv4 路由(不满足 SLA 标准的 BGP 路由使用普通的 route-map-out-vpnv4)。route-map <string>:引用 Route Map 操作本地宣告的 BGP 路由。redistribute <string>:在重发布中调用 Route Map。
config router bgp
set as <AS_number>
config neighbor
edit <ip>
set remote-as <AS_number>
config conditional-advertise
edit <advertise-routemap>
set condition-routemap <name1>, <name2>, ...
set condition-type {exist | non-exist}
next
end
next
end
end<advertise-routemap>:引用 Route Map 匹配要宣告的网络。condition-routemap <name1>, <name2>, ...:Route Map 匹配条件的路由是否存在于路由表。