How to use nmcli to create / add bridges in Linux
Today, I would like to share with you how to use nmcli to create / add bridges in Linux. The content is detailed and the logic is clear. I believe most people still know too much about this knowledge, so share this article for your reference. I hope you can get something after reading this article.
How to use nmcli to create / add a bridge the steps to add a bridge interface on Linux using NetworkManager are as follows:
Open the terminal
Get the current connection status: nmcli con show
Add a new bridge: nmcli con add type bridge ifname br0
Create a subnet card: nmcli con add type bridge-slave ifname eno1 master br0
Open br0: nmcli con up br0
Let's look at how to create a bridge called br0 at the level of detail.
To get the current network configuration, you can learn about the local network connection through NetworkManager's GUI:
Getting Network Info on Linux
You can also view it using the following command line:
$nmcli con show $nmcli connection show-- active
View the connections with nmcli
I have a "wired connection" using the network card eno1. My system also has a VPN interface. I'm going to create a bridge called br0 and connect to eno1.
How to create a bridge named br0 $sudo nmcli con add ifname br0 type bridge con-name br0 $sudo nmcli con add type bridge-slave ifname eno1 master br0 $nmcli connection show
Create bridge interface using nmcli on Linux
You can also disable STP:
The last command of $sudo nmcli con modify br0 bridge.stp no $nmcli con show $nmcli-f bridge con show br0 shows the bridge parameters when STP is disabled:
Bridge.mac-address:-- bridge.stp: no bridge.priority: 32768 bridge.forward-delay: 15 bridge.hello-time: 2 bridge.max-age: 20 bridge.ageing-time: 300 bridge.multicast-snooping: how to open a bridge in yes you must first close Wired connection 1 Then open br0:
$sudo nmcli con down "Wired connection 1" $sudo nmcli con up br0 $nmcli con show uses the ip command to view IP information:
$ip a s $ip a s br0
Build a network bridge with nmcli on Linux
Appendix: how to use br0 on KVM now you can use the VM (virtual machine) created by KVM/VirtualBox/VMware workstation to connect directly to the network instead of through NAT. Use the vi or cat command to create a file called br0.xml for the virtual machine:
$cat / tmp/br0.xml add the following code:
Br0 runs the virsh command as follows:
# virsh net-define / tmp/br0.xml # virsh net-start br0 # virsh net-autostart br0 # virsh net-list-- all output:
Name State Autostart Persistent-br0 active yes yes default inactive no yes read the man page for more information:
The above $man ip $man nmcli is all the content of the article "how to use nmcli to create / add bridges in Linux". Thank you for reading! I believe you will gain a lot after reading this article. The editor will update different knowledge for you every day. If you want to learn more knowledge, please pay attention to the industry information channel.