Add a Virtual Bridge Using NMCLI

virtual bridge nmcli

Adding a virtual bridge using nmcli involves several steps. A virtual bridge is commonly used in networking to connect multiple virtual or physical network interfaces.

Table of Contents

Introduction

In networking, a virtual bridge serves as a crucial component for connecting and managing multiple network interfaces. It allows for the creation of a unified network infrastructure, whether for virtual machines or physical devices. The NetworkManager Command-Line Interface (nmcli) is a powerful tool for configuring network connections on Linux systems.

virtual bridge nmcli: ethernet cables

Photo by Pixabay from Pexels

This guide outlines the steps to create a virtual bridge using nmcli, providing a seamless way to consolidate network interfaces and enhance connectivity. Here are the steps:

Check Existing Connections

Before creating a bridge, it’s good to check existing network connections. You can use the following command to list available connections:

				
					$ nmcli connection show
				
			

Abbreviations of this command like nmcli con show or nmcli c s will work as well.

Create Bridge Connection

Use nmcli to create a new bridge connection. For this example, we will use br0 as the desired bridge name.

				
					$ nmcli connection add type bridge ifname br0
				
			

Add Interfaces

Add the network interfaces you want to include in the bridge. Replace enp0s1 and enp0s2 with the actual interface names you’d like to include as yours will be different.

				
					$ nmcli connection add type bridge-slave ifname enp0s1 master br0
$ nmcli connection add type bridge-slave ifname enp0s2 master br0
				
			

Activate Bridge Connection

Activate the bridge connection to apply the changes.

				
					$ nmcli connection up br0
				
			

Verify Configuration

Confirm that the bridge and its associated interfaces are configured correctly.

				
					$ nmcli connection show
				
			

Check Status

Ensure that the bridge connection is active and the interfaces are part of the bridge.

				
					$ nmcli con show --active
				
			

Configure IP address

If needed, you can assign an IP address to the bridge interface.

				
					$ nmcli connection modify br0 ipv4.addresses 192.168.2.2/24
$ nmcli connection modify br0 ipv4.method manual
				
			

Adjust the IP address and subnet mask according to your network configuration.

Activate Changes

Activate the changes to apply the IP address configuration.

				
					$ nmcli connection up br0
				
			

Verify IP Configuration

Confirm that the IP address is assigned to the bridge interface.

				
					$ nmcli con show br0 | grep addresses
802-3-ethernet.accept-all-mac-addresses:-1 (default)
ipv4.addresses:                         192.168.2.2/24
ipv6.addresses:                         --
				
			

These steps assume you are using NetworkManager and nmcli on a Linux system (e.g. Redhat or CentOS). Adjust the commands and interface names based on your specific requirements and system configuration.

Conclusion

In conclusion, utilizing the nmcli tool to create a virtual bridge offers an effective solution for managing multiple network interfaces within a Linux environment. The step-by-step guide provided above enables users to seamlessly integrate interfaces into a unified bridge, enhancing network connectivity and facilitating efficient communication between devices. 

Whether for virtual machines or physical systems, the virtual bridge configuration, coupled with IP address assignment, ensures a well-organized and responsive network infrastructure. By following these steps, users can harness the power of nmcli to streamline network management, contributing to a more robust and interconnected computing environment.

We hope you found this guide helpful and informative. Share your thoughts and ideas with us in the comments section below.

Related Posts

Leave a Reply

Your email address will not be published. Required fields are marked *