网络实验 文档 打开模拟器 →

BGP — 使用正则匹配的 expanded community-list

标准 community-list 进行精确值匹配。Expanded community-list 允许针对打印形式 <asn>:<n> 做正则匹配 — 适合「匹配以 65001: 开头的任何 community」。通过给前缀打上 65001:777 标签、定义 expanded 列表 ^65001: 并验证带标前缀匹配来演示。

在浏览器中打开本实验 →

免费 · 无需安装 · 无需注册

场景

两种 community-list 形式: | 类型 | 匹配形式 | 用例 | | --- | --- | --- | | standard | 精确值(如 65001:100)| 「community 恰好为 X 时放行」| | expanded | 在打印字符串上做正则 | 「community 为 65001:* 时放行」| Expanded 针对 COMMUNITIES 属性,渲染为以空格分隔的 <asn>:<n> 字符串 —— 同时携带两个时形如 65001:100 65001:200。用 ^ / $ 锚定;用 \b 表示单词边界。 「netverdict 相对真实 Cisco 的偏离」:真实 IOS 把 _ 当作边界元字符(匹配空格、逗号、起始、末尾)。netverdict 直接使用 JavaScript 的 RegExp —— 边界请改用 \b。 本实验中 R1 给 192.168.1.0/24 打上 65001:777 标签。R2 定义 expanded 列表 ^65001: 并确认带标前缀匹配。

拓扑

2 × 路由器 · Cisco IOS-style

你将完成的任务

  1. 在 R1 上定义一个 route-map,将出方向前缀打上 community 65001:777,并绑定到 eBGP 邻居。(复用 np-bgp-community-tag-and-filter 的模式。)

  2. 在 R2 上定义一个 *expanded* community-list ANY-65001,匹配 ^65001:(AS 部分为 65001 的任何 community)。

  3. 在 R2 上定义 route-map MATCH-65001 permit 10,包含 match community ANY-65001 和 set local-preference 200。在面向 R1 的入方向绑定。

在浏览器中打开本实验 →

同主题的更多实验

本实验的其他语言版本

BGP — expanded community-list with regex matchBGP — expanded Community-List mit Regex-MatchBGP — community-list expandida con regexBGP — community-list expandida com match regexBGP — community-list expanded avec match regexBGP — regex match के साथ expanded community-listBGP — community-list expanded con match regexBGP — 正規表現マッチ付き expanded community-listBGP — 정규식 매치를 가진 expanded community-listBGP — expanded community-list с regex-совпадениемBGP — regex eşleşmeli expanded community-listBGP — community-list expanded khớp regex