show mac サブコマンド¶
概要¶
show mac は FDB (Forwarding Database) のエントリ(MAC アドレス学習テーブル)を表示する。実装は fdbshow スクリプトの薄いラッパで、CLI 側はオプションを fdbshow の引数に machine-translate するだけ1。invoke_without_command="true" の Click group なので、サブコマンドなしで呼ぶと FDB を、aging-time を指定すると別系統 (APPL_DB) を読みに行く。
コマンド一覧¶
| コマンド | 用途 |
|---|---|
show mac [options] |
FDB エントリの表示 |
show mac aging-time |
スイッチの FDB エージング時間(秒) |
各コマンドの詳細¶
show mac [options]¶
用法:
show mac
[-v|--vlan <vlan>]
[-p|--port <port>]
[-a|--address <mac>]
[-t|--type <static|dynamic>]
[-c|--count]
[-n|--namespace <ns>]
[--verbose]
オプション:
-v / --vlan... 特定 VLAN の FDB のみ-p / --port... 特定ポート上の FDB のみ-a / --address... 指定 MAC アドレス-t / --type...static/dynamicのみ-c / --count... 件数表示モード(エントリ一覧の代わりに件数のみ)-n / --namespace... multi-ASIC 環境向け
動作:
fdbshow コマンドにフラグを渡して exec する。例: --vlan 100 --port Ethernet0 の場合は fdbshow -v 100 -p Ethernet0。
📋 検証エビデンス: sonic-net/sonic-utilities/show/main.py#L1199-L1244 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
出典:
sonic-net/sonic-utilities/show/main.py#L1199-L1244 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
抜粋:
@cli.group(cls=clicommon.AliasedGroup, invoke_without_command="true")
def mac(ctx, vlan, port, address, type, count, verbose, namespace):
if ctx.invoked_subcommand is not None:
return
cmd = ["fdbshow"]
if vlan is not None: cmd += ['-v', str(vlan)]
if port is not None: cmd += ['-p', str(port)]
if address is not None: cmd += ['-a', str(address)]
if type is not None: cmd += ['-t', str(type)]
if count: cmd += ["-c"]
if namespace is not None: cmd += ['-n', str(namespace)]
run_command(cmd, display_cmd=verbose)
show mac aging-time¶
用法:
動作:
FDB 表示とは別系統 で、SonicV2Connector 経由で APPL_DB の SWITCH_TABLE* を列挙し、各キーから fdb_aging_time を取得して表示する2。設定されていなければ Aging time not configured for the switch を出力。
📋 検証エビデンス: sonic-net/sonic-utilities/show/main.py#L1245-L1262 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
出典:
sonic-net/sonic-utilities/show/main.py#L1245-L1262 (sha: 39732bceb8bdefe706518ab40623bbbba6ff33b9)
抜粋:
補足¶
fdbshow自体は APPL_DB / ASIC_DB / STATE_DB を読み合わせて FDB を組み立てる。CONFIG_DB は使わない- aging time の 設定 は
config mac aging_time <seconds>等が存在する場合に行う(本ページは表示系のみ)
データフロー (自動生成)¶
flowchart LR
CLI["show mac"]
SRC0[("APP_DB<br/>FDB_TABLE / STATE_DB<br/>FDB_TABLE")]
V0["fdbshow"]
SRC0 --> V0 --> CLI
凡例
show 系 (データソース → ラッパスクリプト → CLI) のミニ図。CONFIG_DB は経由しない。
関連リファレンス¶
- (関連リンクなし)
引用元¶
実行例¶
典型的な使い方¶
よくある引数の組み合わせ¶
期待される出力 (抜粋)¶
No. Vlan MacAddress Port Type
----- ------ ----------------- ------------- ---------
1 100 00:11:22:33:44:55 Ethernet0 Dynamic
2 100 00:11:22:33:44:66 Ethernet4 Dynamic
関連 CLI コマンド¶
config interface— config interface サブコマンドconfig portchannel— config portchannel サブコマンドconfig vlan— config vlan サブコマンドshow lldp— show lldp サブコマンドshow storm control— show storm-control サブコマンド
関連ページ¶
-
https://github.com/sonic-net/sonic-utilities/blob/39732bceb8bdefe706518ab40623bbbba6ff33b9/show/main.py#L1199 ↩
-
APPL_DB の
SWITCH_TABLEは orchagent が書き込む。fdb_aging_timeは秒単位。 ↩