Detailed tutorial on configuring the bridge on Ubuntu system

Time:2022-8-2

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.
requirement

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.

   

Copy code

The code is as follows:

[$ apt-cache show network-manager | grep Version</p>
<p> Version: 0.9.10.0-4ubuntu15.1
Version: 0.9.10.0-4ubuntu15

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.

   

Copy code

The code is as follows:

$ nm-connection-editor

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.
2015529191633168.jpg (400×328)

Next, select “bridge” as the connection type.
2015529191705749.jpg (539×295)

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.
2015529191727569.jpg (520×538)

Select “Ethernet” as the connection type.
2015529191749208.jpg (539×291)

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.
2015529191810896.jpg (567×402)

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”.
2015529191831821.jpg (567×402)

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.
2015529191927094.jpg (400×328)

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.
2015529192013614.jpg (800×351)

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.
2015529192305131.jpg (716×315)

That’s all. Now, the bridge is ready to use.