6.3. Using the NetworkManager Command Line Tool, nmcli
To create a bridge, with name
bridge-br0, issue a command as follows:
~]$ nmcli con add type bridge ifname br0
Connection 'bridge-br0' (79cf6a3e-0310-4a78-b759-bda1cc3eef8d) successfully added.
If no interface name is specified, the name will default to
bridge,
bridge-1,
bridge-2, and so on.
To view the connections, issue the following command:
~]$ nmcli con show conf
NAME UUID TYPE TIMESTAMP-REAL
eth0 4d5c449a-a6c5-451c-8206-3c9a4ec88bca 802-3-ethernet Mon 21 Oct 2013 16:01:53 BST
bridge-br0 79cf6a3e-0310-4a78-b759-bda1cc3eef8d bridge never
Spanning tree protocol (
STP) according to the IEEE 802.1D standard is enabled by default. To disable
STP
for this bridge, issue a command as follows:
~]$ nmcli con bridge-br0 stp no
To re-enable
802.1D STP
for this bridge, issue a command as follows:
~]$ nmcli con bridge-br0 stp yes
The default bridge priority for
802.1D STP
is
32768
. The lower number is preferred in root bridge selection. For example, a bridge with priority of
28672
would be selected as the root bridge in preference to a bridge with priority value of
32768
(the default). To create a bridge with a non-default value, issue a command as follows:
~]$ nmcli con add type bridge ifname br5 stp yes priority 28672
Connection 'bridge-br5' (86b83ad3-b466-4795-aeb6-4a66eb1856c7) successfully added.
The allowed values are in the range
0
to
65535
, but can only be set in multiples of
4096
.
To change the bridge priority of an existing bridge to a non-default value, issue a command in the following format:
~]$ nmcli connection modify bridge-br5 bridge.priority 36864
The allowed values are in the range
0
to
65535
, but can only be set in multiples of
4096
.
Further options for 802.1D STP
are listed in the bridge section of the nmcli(1)
man page.
To add, or enslave an interface, for example
eth1, to the bridge
bridge-br0, issue a command as follows:
~]$ nmcli con add type bridge-slave ifname eth1 master bridge-br0
Connection 'bridge-slave-eth1' (70ffae80-7428-4d9c-8cbd-2e35de72476e) successfully added.
At time of writing,
nmcli only supports Ethernet slaves.
To change a value using interactive mode, issue the following command:
~]$ nmcli connection edit bridge-br0
You will be placed at the
nmcli prompt.
nmcli> set bridge.priority 4096
nmcli> save
Connection 'bridge-br0' (79cf6a3e-0310-4a78-b759-bda1cc3eef8d) successfully saved.
nmcli> quit