微算力 · API 导航与自营网关
API 接入 EN
未登录登录
🔍

BGP协议深度诊断与最优路径分析

Bgp Analysis · v0.1.1
入口已确认,内容待校验 文件树里有 SKILL.md,但正文还没采回,frontmatter 未核对。
专业技能 安全 S+ 级 作者 vahagn-madatyan 公开目录收录
624 下载 0 安装 1.9k 收藏 17 浏览

简介

BGP协议深度诊断工具,支持Cisco/Juniper/Arista多厂商,覆盖对等状态机诊断、最优路径验证、路由过滤校验及收敛性评估,采用纯只读操作确保生产网络安全。

原始描述

BGP protocol analysis with peer state diagnosis, path selection verification, route filtering validation, and convergence assessment. Multi-vendor coverage f...

通过你的 Agent 添加

安装目录:bgp-analysis/(目录名取自 SKILL.md 的 frontmatter name,不是 URL 里的 slug)。

点「快速安装」复制一段指令贴给你的 Agent:它会先下载到 /tmp、把文件清单和校验值给你看,你确认之后才解压安装。不会一步装完、也不改系统其它位置。

或者手动安装

Claude Code~/.claude/skills/bgp-analysis/
Codex CLI~/.codex/skills/bgp-analysis/
DeepSeek Harness~/.agents/skills/bgp-analysis/

包是「根级 SKILL.md + 作者附带的文件」,解压到上面的 <slug>/ 目录即可; 目录名不用换,也不要把包直接解压到 skills 根目录。 技能申请的权限由作者决定:装之前先看清单里有没有脚本、它会读写什么。

中文使用说明 来自收录源

核心用法

该技能提供系统化的BGP协议诊断能力,区别于传统的阈值监控,采用协议状态机推理方法解决复杂路由问题。诊断流程分为六个递进阶段:

  1. 会话清单采集 — 获取所有对等体状态,识别未建立连接
  2. 对等状态诊断 — 基于BGP FSM状态机定位故障域(Idle/Connect/Active/OpenSent/OpenConfirm)
  3. 路由表分析 — 验证前缀交换是否符合预期基线
  4. 路径选择验证 — 逐条遍历最优路径算法,定位意外选路原因
  5. 路由过滤校验 — 验证route-map、前缀列表、团体属性过滤器的应用效果
  6. 收敛性评估 — 检测路由抖动、抑制路由及更新风暴

支持三厂商命令语法:Cisco IOS-XE/NX-OS、Juniper JunOS、Arista EOS,所有命令均标注厂商标签,未标注则为通用语法。

显著优点

  • 协议原生推理:深入BGP状态机和最优路径算法,而非表面指标比对
  • 决策树驱动:提供完整的故障决策树(Peer Not Established / Unexpected Route Selection),降低诊断经验门槛
  • 生产安全:仅使用show类只读命令,无需配置权限,支持SSH/console只读账号
  • 多厂商统一:同一诊断逻辑适配三大主流厂商,减少跨平台学习成本
  • 可量化基准:内置阈值表(Hold Timer、MRAI、表容量规范、收敛目标),支持客观评估

潜在局限

  • 需要拓扑知识:诊断有效性高度依赖操作者对预期对等拓扑、策略意图的了解
  • 非自动化修复:纯诊断技能,不提供自动修复动作,需人工执行配置变更
  • 厂商版本差异:实际命令输出格式可能因OS版本略有不同,需灵活适配
  • iBGP场景复杂:路由反射器拓扑的故障定位需要额外理解RR客户端关系

适合人群

  • 网络运维工程师:日常BGP故障排查、变更后验证
  • 网络架构师:容量规划、收敛性评估、策略设计验证
  • 云网互联工程师:数据中心、云网互联场景的跨厂商BGP对等管理
  • 技术支持/厂商TAC:多厂商环境下标准化诊断流程

常规风险

  • 误读状态机:BGP FSM状态理解错误可能导致错误定位(如将Active状态误判为成功连接)
  • 基线漂移:未建立准确的预期前缀数量基线,导致假阳性/假阴性告警
  • 策略副作用:诊断建议的修复动作(如always-compare-med)可能意外改变其他前缀的选路结果
  • 并发操作风险:虽为只读,但在高CPU负载设备上执行大量show命令可能加剧性能压力
  • 认证信息泄露:邻居详细信息输出中可能包含敏感配置片段(如MD5认证提示),需注意输出脱敏

技能正文


name: bgp-analysis description: >- BGP protocol analysis with peer state diagnosis, path selection verification, route filtering validation, and convergence assessment. Multi-vendor coverage for Cisco IOS-XE/NX-OS, Juniper JunOS, and Arista EOS with protocol-first diagnostic reasoning. license: Apache-2.0 metadata: safety: read-only author: network-security-skills-suite version: "1.0.0" openclaw: '{"emoji":"🔍","safetyTier":"read-only","requires":{"bins":["ssh"],"env":[]},"tags":["bgp","routing","protocol"],"mcpDependencies":[],"egressEndpoints":[]}'

BGP Protocol Analysis

Protocol-reasoning-driven analysis skill for BGP peering, path selection, and route propagation. Unlike device health checks that compare metrics against thresholds, BGP analysis requires interpreting protocol state machines, walking the best-path algorithm, and validating policy application across the control plane.

Commands are labeled [Cisco], [JunOS], or [EOS] where syntax diverges. Unlabeled statements apply to all three vendors.

When to Use

  • BGP peer reported down or stuck in a non-Established state
  • Suspected route leak — prefixes appearing in tables where they should not
  • Path selection not matching expectations after policy changes
  • Convergence too slow after planned maintenance or unplanned failover
  • Post-change verification of BGP configuration (new peers, policy updates, community changes)
  • Capacity planning for prefix table growth or session scaling
  • Investigating asymmetric routing caused by inconsistent BGP attributes

Prerequisites

  • SSH or console access to the router (read-only privilege sufficient)
  • BGP process running on the device with at least one configured peer
  • Knowledge of expected peer topology: which neighbors should be up, expected prefix counts per peer, intended path selection outcomes
  • Awareness of configured routing policy: route-maps, prefix-lists, community filters, AS-path access lists, and local-preference assignments
  • For iBGP: understanding of the route-reflector or full-mesh topology

Procedure

Follow this diagnostic flow sequentially. Each step builds on the data from prior steps. The procedure moves from broad inventory to targeted diagnosis.

Step 1: BGP Session Inventory

Collect all peer states and compare against expected topology.

[Cisco]

show bgp ipv4 unicast summary

[JunOS]

show bgp summary

[EOS]

show ip bgp summary

Record each neighbor: address, AS number, state, prefixes received, up/down time. Compare against expected topology — every configured peer should appear. A peer missing from output means it was never configured or was removed. Any peer not showing a numeric prefix count is not Established — proceed to Step 2 for that peer.

Step 2: Peer State Diagnosis

For any peer not in Established state, the BGP FSM state reveals the failure domain. This is the core diagnostic reasoning step.

[Cisco]

show bgp ipv4 unicast neighbors [addr] | include state|last reset|error

[JunOS]

show bgp neighbor [addr] | match "State|Last Error|Last State"

[EOS]

show ip bgp neighbors [addr] | include state|last reset|error

Interpret the FSM state to isolate the failure:

  • Idle → BGP process not attempting connection. Causes: administratively shut down, no route to peer address, configured remote AS does not match, or maximum-prefix limit hit triggering teardown.
  • Connect → TCP SYN sent, waiting for response. Peer is unreachable at Layer 3 or a firewall is blocking TCP port 179.
  • Active → TCP connection attempt failed, retrying. Same causes as Connect but the router has cycled back. Check: ACLs blocking port 179, peer not configured for this neighbor, peer address unreachable.
  • OpenSent → TCP connected, OPEN message sent, no reply. Remote end accepted TCP but is not sending OPEN — typically remote BGP not configured for this neighbor or remote peer in admin shutdown.
  • OpenConfirm → OPEN received but parameters rejected. Check: AS number mismatch, capability negotiation failure (AFI/SAFI mismatch), hold timer negotiation failure, authentication (MD5/TCP-AO) mismatch.

Check "last reset reason" and "last error" fields — they often provide the definitive cause. Reference: references/state-machine.md for full FSM detail.

Step 3: Route Table Analysis

For Established peers, verify prefix exchange matches expectations.

[Cisco]

show bgp ipv4 unicast neighbors [addr] routes | include Total

[JunOS]

show route receive-protocol bgp [addr] table summary

[EOS]

show ip bgp neighbors [addr] received-routes | include Total

Compare received prefix count against baseline. Significant deviation indicates:

  • Drop >10% → upstream is withdrawing routes (maintenance, filter change, or failure)
  • Increase >10% → route leak or new prefixes originated upstream
  • Zero received → peer is Established but sending no routes (missing export policy on JunOS, or outbound filter on remote blocking everything)

Check advertised prefix count similarly — confirm this router is sending the expected number of routes to each peer.

Step 4: Path Selection Verification

When traffic takes an unexpected path, walk the BGP best-path algorithm to identify which attribute is making the selection.

[Cisco]

show bgp ipv4 unicast [prefix] bestpath

[JunOS]

show route [prefix] detail | match "AS path|Local|MED|Weight|preference"

[EOS]

show ip bgp [prefix] detail

The best-path algorithm evaluates in this order (first difference wins):

  1. Weight (Cisco/EOS local, highest wins — JunOS does not use weight)
  2. Local Preference (highest wins, default 100)
  3. Locally originated (network/aggregate preferred over learned)
  4. AS Path length (shortest wins)
  5. Origin (IGP < EGP < Incomplete)
  6. MED (lowest wins, compared only within same neighbor AS by default)
  7. eBGP over iBGP (external preferred)
  8. IGP metric to next-hop (lowest wins)
  9. Router ID (lowest wins, tiebreaker)

Identify which attribute selects the current best path. If unexpected, check the route-map or policy applying that attribute on ingress.

Step 5: Route Filtering Validation

Verify that route-maps, prefix-lists, and community filters apply as intended.

[Cisco]

show bgp ipv4 unicast neighbors [addr] policy

[JunOS]

show policy [policy-name] | display detail

[EOS]

show route-map [name]

For suspected route leaks: examine the RIB for prefixes that should not be present. Check inbound filters on the peer that is the source. Common leak causes: missing or misordered prefix-list entry, regex error in AS-path filter, community match that is too broad.

For missing routes: verify the outbound policy on the advertising peer is not filtering the prefix. On JunOS, a peer with no export policy sends nothing by default — this is the most common JunOS-specific omission.

Step 6: Convergence Assessment

Evaluate convergence behavior and route stability.

[Cisco]

show bgp ipv4 unicast dampening dampened-paths

[JunOS]

show route damping suppressed

[EOS]

show ip bgp dampening dampened-paths

Check for dampened (suppressed) routes — these indicate persistent flapping. Review the BGP update activity: high update/withdrawal rates indicate churn. After a planned change, measure convergence time from the change event to the last BGP update. Compare against the target convergence window.

Threshold Tables

Operational parameter norms for BGP — these are protocol-level expectations, not device resource thresholds.

Parameter Cisco Default JunOS Default EOS Default Notes
Hold Timer 180s 90s 180s Negotiated to lower value
Keepalive Interval 60s 30s 60s Hold/3 by convention
ConnectRetry Timer 120s Varies 120s Time between TCP attempts
MRAI (eBGP) 30s 0s (immediate) 30s Minimum Route Advertisement Interval
MRAI (iBGP) 5s 0s 5s Lower than eBGP for faster iBGP convergence
Default Local Pref 100 100 100 Same across vendors

Table Size Norms (IPv4 unicast):

Deployment Type Expected Prefixes Warning Critical
Internet edge (full table) ~950K >1M >1.1M
Internet edge (partial) 5K–100K Varies Per design
Enterprise WAN 100–10K >2x baseline >5x baseline
Data center leaf 50–5K >2x baseline >5x baseline

Convergence Targets:

Scenario Target Acceptable Degraded
eBGP failover < 90s 90–180s > 180s
iBGP reconvergence < 30s 30–60s > 60s
Full table reload < 5min 5–10min > 10min

Decision Trees

Peer Not Established

Peer not in Established state
├── State: Idle
│   ├── Admin shut? → Check config for "neighbor shutdown" / "deactivate"
│   ├── No route to peer? → Check IGP/static route to peer address
│   ├── Prefix-limit exceeded? → Check logs for max-prefix teardown
│   └── AS mismatch? → Verify "remote-as" matches peer's local AS
│
├── State: Connect / Active
│   ├── Peer reachable? → Ping/traceroute peer address
│   │   ├── No → Fix Layer 3 reachability (IGP, static route)
│   │   └── Yes → TCP port 179 blocked?
│   │       ├── ACL on local device? → Check interface/control-plane ACL
│   │       ├── ACL on remote device? → Check remote inbound ACL
│   │       └── Firewall between peers? → Verify TCP/179 permitted both directions
│   └── Peer configured? → Verify remote has this router as neighbor
│
├── State: OpenSent
│   ├── Remote not sending OPEN → Peer may not be configured for this neighbor
│   ├── TCP resets after connect → Check for TTL issues (eBGP multihop)
│   └── Authentication? → Verify MD5/TCP-AO passwords match both sides
│
├── State: OpenConfirm
│   ├── Capability mismatch? → Check AFI/SAFI (IPv4/IPv6/VPNv4) match
│   ├── AS mismatch in OPEN? → Verify configured AS matches OPEN AS
│   ├── Hold timer = 0 on one side? → Both peers must agree or both use 0
│   └── Check NOTIFICATION message → Decode error code/subcode
│
└── Established but dropping
    ├── Hold timer expiry? → Keepalives not arriving (CPU, QoS, path issue)
    ├── NOTIFICATION received? → Decode error code for root cause
    ├── Route refresh storm? → Peer sending excessive route-refresh requests
    └── Max-prefix limit? → Peer sending more prefixes than limit allows

Unexpected Route Selection

Wrong path selected for prefix
├── Check Weight (Cisco/EOS only)
│   └── Weight set via route-map? → Highest weight wins
├── Check Local Preference
│   └── Local pref differs? → Set via inbound route-map; highest wins
├── Check AS Path Length
│   ├── AS prepending applied? → Verify prepend count
│   └── AS path differs? → Shortest wins
├── Check Origin
│   └── IGP vs Incomplete? → IGP (network statement) preferred
├── Check MED
│   ├── MED comparison enabled across AS? → "always-compare-med"
│   └── MED set correctly? → Lowest wins within same neighbor AS
├── Check eBGP vs iBGP
│   └── External path preferred over internal if equal above
├── Check IGP metric to next-hop
│   └── Closest exit wins (hot-potato routing)
└── All equal → Lowest Router ID wins (or oldest route if stable)

Report Template

BGP ANALYSIS REPORT
====================
Device: [hostname]
Vendor: [Cisco | JunOS | EOS]
Check Time: [timestamp]
Performed By: [operator/agent]

SESSION STATUS:
- Total configured peers: [n]
- Established: [n] | Not Established: [n]
- Peers requiring attention: [list with FSM states]

FINDINGS:
1. [Severity] [Category] — [Description]
   Peer: [neighbor address / AS]
   Observed: [state or metric]
   Expected: [normal state or value]
   Root Cause: [diagnosis from decision tree]
   Action: [recommended remediation]

PATH ANALYSIS:
- Prefix: [prefix under review]
- Selected path via: [next-hop / AS path]
- Selecting attribute: [which best-path attribute decided]
- Expected path: [if different, what was expected and why]

ROUTE TABLE SUMMARY:
- IPv4 prefixes received: [total across all peers]
- Baseline deviation: [% change from expected]

RECOMMENDATIONS:
- [Prioritized action list]

NEXT CHECK: [based on severity — CRITICAL: 4hr, WARNING: 24hr, HEALTHY: 7d]

Troubleshooting

Session Flapping

Peer cycles between Established and Idle/Active repeatedly. Common causes: unstable underlying transport (IGP flap, link errors), aggressive hold timers on congested control planes, or MTU issues on the path causing fragmented keepalives to be dropped. Check last reset reason and correlate with interface or IGP events at the same timestamps.

Route Oscillation

The same prefix alternates between two or more paths. Caused by inconsistent MED comparison across route reflectors, or deterministic-MED not enabled when multiple exit points exist to the same neighbor AS. Enable always-compare-med and deterministic-med to stabilize.

Memory Pressure from Full Table

Full Internet table (~950K IPv4 prefixes) requires 1–2 GB of RIB memory depending on path diversity. Symptoms: slow convergence, peer resets during table reload. Mitigate with soft-reconfiguration inbound (trades memory for stability) or ORF (Outbound Route Filtering) to reduce inbound load.

Community Stripping

Routes arrive without expected communities. Check each transit AS in the path — many providers strip non-standard communities by default. Use large communities (RFC 8092) for end-to-end propagation across providers that strip standard communities.

JunOS Default Export Policy

JunOS sends no routes to a peer without an explicit export policy. If a peer shows Established with zero prefixes sent, add an export policy. This is the most common JunOS-specific BGP issue and does not occur on Cisco or EOS.

正文来自原始发布页, 版权归作者所有,许可未标注。 权利人认为有不妥,可申请下架。

标签

bgproutingprotocolciscojuniperaristadiagnosticsnetwork-engineeringread-only

同类 Skill