AS Path List
2025/10/29大约 2 分钟
AS Path List
AS Path List 使用正则表达式来匹配 BGP 路由的 AS_PATH 属性。可用于从 BGP 邻居筛选入站或出站路由,或者作为 Route Map 中的匹配条件,以匹配 BGP 路由中的 AS_PATH 属性。
配置方法
config router aspath-list
edit <name>
config rule
edit <id>
set action {deny | permit}
set regexp <string>
next
end
next
end引用 AS Path List
被 BGP 引用
config router bgp
config neighbor
edit <ip>
set filter-list-in <string>
set filter-list-in6 <string>
set filter-list-out <string>
set filter-list-out6 <string>
next
end
endfilter-list-in <string>:针对该邻居引用 AS Path List 过滤入方向的 IPv4 路由。filter-list-in6 <string>:针对该邻居引用 AS Path List 过滤入方向的 IPv6 路由。filter-list-out <string>:针对该邻居引用 AS Path List 过滤出方向的 IPv4 路由。filter-list-out6 <string>:针对该邻居引用 AS Path List 过滤出方向的 IPv6 路由。
被 Rout Map 引用
config router route-map
edit <name>
config rule
edit <id>
set match-as-path <string>
next
end
next
endmatch-as-path <string>:引用 AS Path List 匹配路由条目。
配置举例
查看设备 BGP 学习到的路由属性,学习到两条 BGP 路由,需要过滤掉 AS Path 起源是 100 的路由。
get router info bgp neighbors 169.254.1.2 routes VRF 0 BGP table version is 1, local router ID is 4.4.4.4 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight RouteTag Path *> 100.100.100.0/24 169.254.1.2 0 0 300 100 i <-/-> //过滤AS Path起源是100的路由// *> 200.200.200.0/24 169.254.1.2 0 0 300 200 i <-/->配置 AS Path List,使用正则表达式匹配 AS Path 末尾是
100结尾的 AS Path。config router aspath-list edit "AS100" config rule edit 1 set action permit set regexp "_100$" next end next end在 Route Map 中引用该 AS Path List,禁止接收匹配该 AS Path List 的路由,其他路由可以正常接收。
config router route-ma edit "RM_INBOUND" config rule edit 1 set action deny set match-as-path "AS100" next edit 2 set action permit next end next end在 BGP 邻居中引用该 Route Map。
config router bgp config neighbor edit "169.254.1.2" set route-map-in "RM_INBOUND" next end end刷新入方向的 BGP 路由,再次查看学习到的 BGP 路由,可以看到起源为 AS 100 的 BGP 路由已经被过滤掉。
FortiGate # get router info bgp neighbors 169.254.1.2 routes VRF 0 BGP table version is 1, local router ID is 4.4.4.4 Status codes: s suppressed, d damped, h history, * valid, > best, i - internal, S Stale Origin codes: i - IGP, e - EGP, ? - incomplete Network Next Hop Metric LocPrf Weight RouteTag Path *> 200.200.200.0/24 169.254.1.2 0 0 0 300 200 i <-/1> Total number of prefixes 1