Thursday, May 1, 2025

Add a Virtual Bridge Using NMCLI

 

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.

No comments:

Post a Comment

HTTP Appache Server LAB 7

 Apache HTTP Server (httpd) Configuration,