A bridge is a hardware device used to interconnect two or more data link layers (the second layer in the OSI seven layer model) so that network devices on different network segments can access each other. When you want to interconnect multiple virtual machines or Ethernet interfaces in a host, you need to have a similar bridge concept in the Linux host. A soft bridge is used here.
There are many ways to configure a Linux bridge. For example, in a server environment without external display / keyboard, you can manually configure a bridge using BRCT. In the desktop environment, the network manager also supports network bridge settings. Let’s test how to configure a bridge with the network manager.
To avoid any problems, it is recommended that your network manager version be 0.9.9 or higher, which is used in Ubuntu 15.04 or later.
The code is as follows:
<p> Version: 0.9.10.0-4ubuntu15.1
Create a bridge
The easiest way to create a bridge using the network manager is through nm connection editor. This GUI (graphical user interface) tool allows you to configure a bridge foolishly.
First, start nm connection editor.
The code is as follows:
The editor window will show you a list of currently configured network connections. Click the “add” button in the upper right corner to create a bridge.
Next, select “bridge” as the connection type.
Now, start configuring the bridge, including its name and the bridged connection. If no other bridge has been created, the default bridge interface will be named bridge0.
Recall that the purpose of creating a bridge is to share your Ethernet card interface through the bridge, so you need to add an Ethernet card interface to the bridge. Adding a new “bridged connection” in the graphical interface can achieve the above purpose. Click the “add” button.
Select “Ethernet” as the connection type.
In the “MAC address of the device” area, select the interface you want to belong to the bridge. In this example, assume that the interface is eth0.
Click the “general” tab and select two check boxes, namely “automatically connect to this network when it is available” and “all users can connect to this network”.
Switch to the “IPv4 settings” tab and configure DHCP or static IP address for the bridge. Note that you should use the same IPv4 settings for the slave Ethernet interface eth0. In this example, we assume that eth0 is configured with DHCP. Therefore, choose “automatic (DHCP)” here. If eth0 is assigned a static IP address, you should also assign the same IP address to the bridge.
Finally, save the bridge settings.
Now, you will see a new bridge connection created in the “network connection” window. Because it is dependent on the bridge, the previously configured wired connection eth0 is no longer needed, so delete the original wired connection.
At this time, the bridge connection will be automatically activated. Since the IP address assigned to eth0 is taken over by the bridge, you will temporarily lose your connection. When the IP address is assigned to the bridge, you will connect back to your Ethernet card interface through the bridge. You can confirm it through the “network” setting.
At the same time, check the available interfaces. As a reminder, the bridge interface must have replaced any IP address owned by your Ethernet card interface.
That’s all. Now, the bridge is ready to use.