Show Table of Contents
6.2. NetworkManager のコマンドラインツール nmcli の使用
bridge-br0 という名前のブリッジを作成するには、
root で以下のコマンドを実行します。
~]# nmcli con add type bridge ifname br0
Connection 'bridge-br0' (6ad5bba6-98a0-4f20-839d-c997ba7668ad) successfully added.
インターフェース名が指定されない場合は、デフォルトの bridge、bridge-1、bridge-2 といった名前が付けられます。
接続を表示するには、以下のコマンドを実行します。
~]$ nmcli con show
NAME UUID TYPE DEVICE
bridge-br0 79cf6a3e-0310-4a78-b759-bda1cc3eef8d bridge br0
eth0 4d5c449a-a6c5-451c-8206-3c9a4ec88bca 802-3-ethernet eth0
デフォルトでは、スパニングツリープロトコル (STP) が有効になっています。使用される値は、IEEE 802.1D-1998 標準からのものです。このブリッジでの
STP を無効にするには、root で以下のコマンドを実行します。
~]# nmcli con modify bridge-br0 bridge.stp no
このブリッジで再度 802.1D STP を有効にするには、root で以下のコマンドを実行します。
~]# nmcli con modify bridge-br0 bridge.stp yes
802.1D STP のデフォルトのブリッジ優先度は 32768 です。root ブリッジ選択では、少ない値が選ばれます。たとえば、優先度 32768 (デフォルト) よりも 28672 のブリッジが root ブリッジに選ばれます。デフォルト値以外の値のブリッジを作成するには、以下のコマンドを実行します。
~]$ nmcli con add type bridge ifname br5 stp yes priority 28672
Connection 'bridge-br5' (86b83ad3-b466-4795-aeb6-4a66eb1856c7) successfully added.
0 から 65535 までの値が使用できます。
既存ブリッジのブリッジ優先度をデフォルト値以外の値に変更するには、以下の形式のコマンドを実行します。
~]$ nmcli connection modify bridge-br5 bridge.priority 36864
0 から 65535 までの値が使用できます。
ブリッジの設定を表示するには、以下のコマンドを実行します。
~]$ nmcli -f bridge con show bridge-br0
802.1D STP の他のオプションについては、nmcli(1) man ページのブリッジセクションに記載されています。
たとえばインターフェース eth1 を bridge-br0 に追加もしくはスレーブ化するには、以下のコマンドを実行します。
~]$ nmcli con add type ethernet ifname eth1 master bridge-br0
Connection 'bridge-slave-eth1' (70ffae80-7428-4d9c-8cbd-2e35de72476e) successfully added.
本ガイド執筆時点では、nmcli がサポートするのはイーサネットのスレーブのみです。
インタラクティブモードを使って値を変更するには、以下のコマンドを実行します。
~]$ nmcli connection edit bridge-br0
これで nmcli プロンプトが表示されます。
nmcli>set bridge.priority 4096nmcli>saveConnection 'bridge-br0' (79cf6a3e-0310-4a78-b759-bda1cc3eef8d) successfully saved. nmcli>quit
nmcli の導入については、「NetworkManager コマンドラインツール (
nmcli) の使用」を参照してください。

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.