首页/网络/BGP 与广域网速查/华为 as-path-filter:正则过滤 AS_PATH
路由过滤与重分发66 条

华为 as-path-filter:正则过滤 AS_PATH

华为用 ip as-path-filter 定义 AS 路径正则,配合 filter-policy as-path-filter 或 route-policy if-match 使用;正则元字符与 Cisco 语义一致,但定义与引用语法不同。

BGP 与广域网速查网络更新于 2026-10-12
定义ip as-path-filter <号> permit|deny <正则>
应用一filter-policy as-path-filter <号> import/export
应用二route-policy 中 if-match as-path-filter <号>
查看display ip as-path-filter

示例

示例
ip as-path-filter 10 permit ^65002$
ip as-path-filter 10 permit ^65002 65003
!
bgp 65001
 ipv4-family unicast
  peer 10.0.0.2 as-number 65002
  peer 10.0.0.2 enable
  filter-policy as-path-filter 10 import
!
display bgp routing-table

易错点

  • 锚点写错:AS_PATH 是空格分隔串,漏写 $ 会匹配到子串
  • filter-policy 与 route-policy 引用方式不同:核对配置中实际引用点

数据来源与参考

  • 华为: ip as-path-filter 命令参考
  • RFC 4271: AS_PATH 属性
​‌‌​​‌​​​‌‌​‌‌‌‌​‌‌​​​‌‌​‌‌‌​​‌‌​​‌​‌‌‌​​‌‌‌​​​‌​‌‌​‌​​‌​‌‌‌​​​‌​‌‌​‌​​‌​‌‌​​​‌‌​‌‌‌​‌​​​‌‌​‌‌‌‌​​‌​‌‌‌​​‌‌​​​‌‌​‌‌​‌‌‌‌​‌‌​‌‌​‌