Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
3 Ways to Create a Network Bridge in RHEL CentOS 8
A network bridge is a software component that allows multiple networks to be connected together, creating a larger network that can be used to share resources and communicate between devices. In Red Hat Enterprise Linux (RHEL) and CentOS 8, network bridging can be achieved in several ways, depending on your needs and preferences.
In this article, we will explore three primary methods to create a network bridge in RHEL/CentOS 8, using examples and step-by-step instructions. Whether you need to connect virtual machines or physical devices, these methods will help you set up a bridge that meets your requirements.
Method 1: Using nmcli Command Line Tool
The nmcli command line tool is a powerful utility for managing network connections in RHEL/CentOS 8. It can be used to create, modify, and delete network connections, including network bridges.
Step 1 Check Network Interfaces
Before creating a network bridge, you need to identify network interfaces that you want to bridge. Use the following command to list all available network interfaces on your system
nmcli device status
This command will show a list of network interfaces, along with their connection status and device type.
Step 2 Create a New Bridge Connection
To create a new bridge connection, use the following command
sudo nmcli connection add type bridge ifname br0
This command creates a new bridge connection with the name br0. You can replace br0 with any name you prefer.
Step 3 Add Network Interfaces to Bridge
To add network interfaces to the bridge, use the following command
sudo nmcli connection add type bridge-slave ifname eth0 master br0
Replace eth0 with the name of the network interface you want to add to the bridge. You can add multiple network interfaces by running this command multiple times with different interface names.
Step 4 Activate Bridge Connection
To activate the bridge connection, use the following command
sudo nmcli connection up br0
This command will bring up the bridge connection and activate it. Now, any device connected to network interfaces that you added to the bridge will be able to communicate with other devices on the same network.
Method 2: Using NetworkManager GUI
If you prefer a graphical user interface (GUI) over command line, you can use NetworkManager GUI to create a network bridge in RHEL/CentOS 8.
Step 1 Open NetworkManager GUI
Open NetworkManager GUI by clicking on the network icon in the system tray, then selecting Network Settings option.
Step 2 Create a New Bridge Connection
In NetworkManager GUI, click on the + button to add a new connection. Select Bridge option and click Create.
Step 3 Configure Bridge Connection
In the bridge connection settings, give the bridge a name (such as br0) and select network interfaces that you want to add to the bridge. You can also configure other settings, such as IP address and DNS servers, if needed.
Step 4 Activate Bridge Connection
Click on the toggle button to activate the bridge connection. Now, any device connected to network interfaces that you added to the bridge will be able to communicate with other devices on the same network.
Method 3: Using Network Scripts (Legacy Method)
Another way to create a network bridge in RHEL/CentOS 8 is by using network-scripts. This method involves manually editing configuration files to create a bridge and assign network interfaces to it. While it provides greater control over bridge configuration, it's considered a legacy approach.
Step 1 Install Bridge Utilities
Before creating a bridge using network-scripts, you need to install the bridge-utils package
sudo dnf install bridge-utils
Step 2 Create Bridge Configuration File
Create a new ifcfg file for the bridge
sudo vi /etc/sysconfig/network-scripts/ifcfg-br0
Add the following configuration
DEVICE=br0 TYPE=Bridge BOOTPROTO=static IPADDR=192.168.1.100 NETMASK=255.255.255.0 GATEWAY=192.168.1.1 ONBOOT=yes
Replace the IP address, netmask, and gateway with values appropriate for your network.
Step 3 Configure Network Interfaces
Edit the network interface configuration files to assign them to the bridge. For example, to bridge eth0
sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0
Add the following lines
DEVICE=eth0 ONBOOT=yes BRIDGE=br0
Step 4 Restart NetworkManager Service
After editing the configuration files, restart the NetworkManager service to apply changes
sudo systemctl restart NetworkManager.service
Verify the bridge status using
sudo brctl show
Comparison of Methods
| Method | Ease of Use | Flexibility | Best For |
|---|---|---|---|
| nmcli | Medium | High | Command-line users, automation |
| NetworkManager GUI | High | Medium | Desktop users, beginners |
| Network Scripts | Low | Very High | Advanced users, custom configurations |
Conclusion
Creating a network bridge in RHEL/CentOS 8 can be accomplished through multiple methods, each suited for different user preferences and requirements. The nmcli tool offers the best balance of power and simplicity, while NetworkManager GUI provides an intuitive interface for desktop users. Choose the method that best fits your environment and technical expertise.
