コンテンツにスキップ

show bgp / show ip bgp / show ipv6 bgp サブコマンド

概要

BGP 状態表示用の CLI は 3 系統に分かれている:

  1. show bgp ... ... CONFIG_DBBGP_DEVICE_GLOBAL / BGP_AGGREGATE_ADDRESSshow/bgp_cli.py が直接 dump(FRR を経由しない)。
  2. show ip bgp ... / show ipv6 bgp ... ... show/bgp_frr_v4.py / bgp_frr_v6.pyvtysh -c "show ip bgp ..." を内部実行して FRR の出力を整形。
  3. show running-configuration bgp ... show/main.pyvtysh -c "show running-config" を実行(別ページ「show running-config」を参照)。

show bgp グループは show/main.py 末尾で cli.add_command(bgp_cli.BGP) の形で登録される1ため、cli.json の機械抽出には現れない。本ページではこの隠れたサブグループを含めて整理する。

コマンド一覧

show bgp ... (CONFIG_DB 直接 dump、FRR 不経由)

コマンド 用途
show bgp device-global [-j\|--json] TSA / W-ECMP の現在状態を CONFIG_DB から表示
show bgp aggregate-address ipv4 [-j\|--json] IPv4 集約 prefix の設定一覧
show bgp aggregate-address ipv6 [-j\|--json] IPv6 集約 prefix の設定一覧

show ip bgp ... / show ipv6 bgp ... (FRR 経由)

コマンド 用途
show ip bgp summary [-n NS] [--display NS_OR_ALL] IPv4 BGP セッションサマリ
show ip bgp neighbors [<ipaddress>] [routes\|advertised-routes\|received-routes] [-n NS] 隣接情報
show ip bgp network [<ip\|prefix>] [bestpath\|json\|longer-prefixes\|multipath] [-n NS] RIB の prefix lookup
show ip bgp aggregate-address bgp_cli の IPv4 aggregate 表示への shim
show ip bgp vrf <vrf> summary / neighbors ... / network ... VRF 配下の BGP 情報(パラメータは default VRF と同じ)
show ipv6 bgp summary / neighbors / network / vrf ... IPv6 版(IPv4 と同等の subcommand 体系)

各コマンドの詳細

show bgp device-global [-j]

db.cfgdb.get_table(BGP_DEVICE_GLOBAL)['STATE'] を読み、tsa_enabled / wcmp_enabledto_strYes/No 形式に変換して表示する。--json{"tsa": ..., "w-ecmp": ...} の dict 出力。CONFIG_DB に未設定なら No configuration is present in CONFIG DB と表示して exit 02

📋 検証エビデンス: sonic-net/sonic-utilities/show/bgp_cli.py#L57-L130 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)

出典:

sonic-net/sonic-utilities/show/bgp_cli.py#L57-L130 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)

抜粋:

@BGP.command(name="device-global")
def DEVICE_GLOBAL(ctx, db, json_format):
    ...
    table = db.cfgdb.get_table(CFG_BGP_DEVICE_GLOBAL)
    entry = table.get(BGP_DEVICE_GLOBAL_KEY, {})

show bgp aggregate-address <ipv4|ipv6>

BGP_AGGREGATE_ADDRESS テーブルから該当 family のエントリを抽出し、bbr-required / summary-only / as-set / aggregate-address-prefix-list / contributing-address-prefix-list をテーブル表示する。

show ip bgp summary [-n] [--display]

bgp_util.get_bgp_summary_from_all_bgp_instances(IPV4, namespace, display, vrf=default) で各 namespace の bgpd から取得した summary を集約。multi-ASIC では --displayfrontend(external 隣接)/ all(internal 隣接含む)を切り替える3

show ip bgp neighbors [<ipaddress>] [<info_type>]

内部で vtysh -c "show ip bgp vrf default neighbor [<ip> [routes|advertised-routes|received-routes]]" を組み立てて FRR コンテナ内で実行する。引数の <info_type><ipaddress> を指定したときのみ意味を持つ。

<ipaddress> を指定すると bgp_util.get_namespace_for_bgp_neighbor が当該 IP を持つ namespace を逆引きし、-n の値と矛盾していれば警告して 実 namespace を優先 する。

show ip bgp network [<ip|prefix>] [<info_type>]

info_typebestpath / json / longer-prefixes / multipath の Choice。longer-prefixesprefix(/ を含む)指定時のみ 有効で、IP 単独で渡すと Abort する4。chassis supervisor では rexec all 経由で全ライン カードで実行される。

show ip bgp vrf <vrf> {summary|neighbors|network}

vrf を click context の親 group から取り出し、ヘルパに vrf=<name> を渡して default と同じパスを通す。VNet 名も VRF として扱う。

IPv6 (show ipv6 bgp ...)

bgp_frr_v6.py の構造は v4 と完全に対称で、内部で組み立てる FRR コマンドが show ipv6 bgp ... になるだけ。bestpath / longer-prefixes 等の制約も同じ。

内部呼び出し

CLI 内部実行
show ip bgp summary bgp_util.get_bgp_summary_from_all_bgp_instancesvtysh -c "show ip bgp vrf <vrf> summary json"
show ip bgp neighbors vtysh -c "show ip bgp vrf <vrf> neighbor ..."
show ip bgp network vtysh -c "show ip bgp vrf <vrf> [<prefix>] [<info_type>]"
show bgp device-global CONFIG_DB の BGP_DEVICE_GLOBAL 直接読み
show bgp aggregate-address CONFIG_DB の BGP_AGGREGATE_ADDRESS 直接読み

vtyshbgp コンテナ内の FRR と通信するため、コンテナ起動前のタイミングではエラーになる。

chassis supervisor の挙動

  • show ip bgp 系の network 以外は、chassis supervisor で叩くと rexec all -c "show ip bgp ..." で全ライン カードに伝搬される5
  • network だけは supervisor 上で直接実行できる。

multi-ASIC オプション

  • -n / --namespace ... 単一 namespace 名 (asic0 等) または all
  • -d / --display ... frontend / allfrontend は external 向けセッションのみ。

データフロー (自動生成)

flowchart LR
  CLI["show bgp"]
  CDB0[("CONFIG_DB<br/>BGP_DEVICE_GLOBAL")]
  CDB0 --> CLI
  CDB1[("CONFIG_DB<br/>BGP_AGGREGATE_ADDRESS")]
  CDB1 --> CLI

凡例

show 系 (CONFIG_DB → CLI) のミニ図。テーブル → daemon 対応は docs/reference/config-db-orch-map.md から機械生成。

関連リファレンス

引用元

実行例

典型的な使い方

# 例 1: BGP セッションサマリ
show ip bgp summary

よくある引数の組み合わせ

# VRF サマリ / IPv6 サマリ
show ip bgp vrf Vrf_Red summary
show ipv6 bgp summary

# 特定隣接の advertised / received routes
show ip bgp neighbors 10.0.0.1 advertised-routes

期待される出力 (抜粋)

Neighbor        V     AS   MsgRcvd   MsgSent   TblVer  InQ OutQ  Up/Down State/PfxRcd
10.0.0.1        4  65100      1023      1019        0    0    0 01:25:34            128
10.0.0.5        4  65100       980       982        0    0    0 01:25:30            128

運用ヒント

典型的な利用シーン

  • BGP セッションが UP しているか、prefix 学習数が想定どおりかをオペ監視で確認する。
  • 障害切り分け時に隣接ステータス・received-routes・advertised-routes を順に追う。

よくある落とし穴

  • show ip bgp summary は default VRF のみで、VRF 設定がある場合は show ip bgp vrf <name> summary を使う。
  • multi-ASIC 機種では -n asic0 などで namespace を明示しないと一部 ASIC の状態が見えない。

関連する show / debug

show ip bgp summary
show ip bgp neighbors 10.0.0.1
show ip bgp network 10.0.0.0/24

関連 CLI コマンド

関連ページ


  1. show/main.py 末尾で cli.add_command(bgp_cli.BGP)show/bgp_cli.pyBGP group が show bgp として登録される)。https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/main.py 

  2. show bgp device-global 実装は show/bgp_cli.py L57-L130。https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/bgp_cli.py#L57 

  3. bgp_frr_v4.pysummary_helper (L160-L164) が bgp_util.get_bgp_summary_from_all_bgp_instancesdisplay を渡す。 

  4. network_helperlonger-prefixes 制約は show/bgp_frr_v4.py L225-L228。https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/bgp_frr_v4.py#L225 

  5. chassis supervisor 分岐は bgp group 関数(L23-L33)で rexec を呼ぶ。