ThirdEyePatch
👁


Bridge Networking


Setting up bridge networking method #1

Bridge networks can be created using a multitude of methods, This first method will be utilizing ifupdown, bridge-utils, and editing the file "/etc/network/interfaces". In this case, we're using base Debian 12, and we are logged in as root, and it's worth noting that to make a bridge network utilizing a wifi device, other steps are required which won't be expounded on in this article. We are using ethernet devices for this guide, and most likely you will too. Typically Debian systems utilize ifupdown, so if you're not using Debian, this method may or may not be applicable.
Start by listing the network interfaces:
"ip a"

Here we see a local loopback (lo) and we see ens3, ens3 being the main interface. Though it may be a different name in your case, for example eth0, ens2, enp1s0, enp9s0, etc. Take note of this interface name. In some cases where you are bridging multiple interfaces, for example you have 2 or 3 ethernet ports you're wanting to bridge, there may be more interface names here, and if so take note of these names if you want to bridge these interfaces. Assuming there are no modifications to the host's interfaces or routing tables, and the interfaces were automatically set up by the host system, continue reading.

We will need one package for this, bridge-utils. Install this now

Now, we will have to make sure no other network daemons other than "networking.service" are enabled on startup, because they may conflict with our configuration. This means if NetworkManager.service or connman.service, systemd-networkd, or any others are enabled, they should be disabled! These names of network daemons are examples and depending on your system, you may have one or several, going by different names.
We'll check this now by using "systemctl status NetworkManager.service" or "systemctl status connman.service" or the name of an equivalent daemon. Then running "systmctl disable NetworkManager.service" The only network daemon we want running is networking.service

Next we will move to the "/etc/network" directory and make a backup of the "interfaces" file using the "mv" command.

Then create a new "interfaces" file in this save directory using your preferred editor, in this case, nano.

Save the file, and reboot the system.
When you log in, run "ip a" to show your network interfaces, where you should see your original interface, and the new "br0" interface with its master being ens3 in this case.

Thats it! you're finished creating your bridge network interface.
You can test connectivity with the ping command:
"ping -c 5 1.1.1.1"

For more detailed information about how to configure ifupdown's interface file, refer to the Manual

Setting up bridge networking method #2

Bridge networks can be created using a multitude of methods, This second method will be using systemd. In this case, we're using base Debian 12, and we are logged in as root, and it's worth noting that to make a bridge network utilizing a wifi device, other steps are required which won't be expounded on in this article. We are using ethernet devices for this guide, and most likely you will too. Other distributions than Debian utilize systemd, so even if you're not using Debian, this method is likely applicable. Start by listing the network interfaces:
"ip a"

Here we see a local loopback (lo) and we see ens3, ens3 being the main interface. Though it may be a different name in your case, for example eth0, ens2, enp1s0, enp9s0, etc. Take note of this interface name. In some cases where you are bridging multiple interfaces, for example you have 2 or 3 ethernet ports you're wanting to bridge, there may be more interface names here, and if so take note of these names if you want to bridge these interfaces. Also take note of the ipv4 address assigned to this interface, in this case 192.168.1.180/24, as to not use the same IP for a static bridge IP later on. Assuming there are no modifications to the host's interfaces or routing tables, and the interfaces were automatically set up by the host system, continue reading.

Now, in order to keep our method using systemd-networkd functional between reboots, we will have to make sure no other network daemons are enabled on startup, because they may conflict with our configuration. This means if NetworkManager.service or connman.service, networking.service, or any others are enabled, they should be disabled! These names of network daemons are examples and depending on your system, you may have one or several, going by different names.
We'll check this now by using "systemctl status networking.service" or "systemctl status connman.service" or the name of an equivalent daemon. Then running "systmctl disable networking.service" The only network daemon we want running is systemd-networkd, to check this use "systemctl status systemd-networkd.service" This output shows systemd-networkd is installed and is disabled. If this service is disabled, enable it now. "systemctl enable systemd-networkd.service"

Now that all the network daemons are disabled except systemd-networkd, and our interfaces file is backed up and renamed, we can move right into creating our configuration files for our bridge. Begin by changing directory into /etc/systemd/network/

"cd /etc/systemd/network/"

Using the editor of your choice, nano in this case, create a new file with the extension ".netdev" in this directory.
I will be naming this "bridge.netdev"

"nano bridge.netdev"

Here we will create the device known as "br0" and specify its type as a bridge.

Save and close the file and create another file in the same directory with the name "1-br0-bind.network" this time with the extension ".network". Because the systemd-networkd daemon will run these files at boot in order based on their name, we will prefix this file with the number 1.

In this configuration file, we set up the bridge device, br0, to bind or use ens3 as its master or main interface. Save and close this file. At this point, we have set up a new bridge device, and bound it to our primary ethernet interface. Depending on whether you would like a static IP assigned to the bridge interface, or let it be assigned by DHCP, there are two options from here.If you want to use DHCP, create a file called "2-br0-dhcp.network"

"nano 2-br0-dhcp.network"

Save and close the file.

You can see I specified a DNS and Gateway address, this is not necessary in all cases, but in my case I did specify.

You could add multiple lines for multiple DNS and Gateway addresses.

If you want to use a static IP address for the host bridge, create a file called "2-br0-static.network" and add the "Address" line set to whichever available ip you desire.



That's it! After creating these three files, reboot your system and use "ip a" to show your network interfaces. Whether you used the DHCP setup or the static IP setup, you'll see something like this shown below, displaying a new interface named br0, with its master being ens3. Here we see the address assigned to this br0 interface automatically set to 192.168.1.247/24. To check for internet connection, you can use ping with a count of 5 to any external ip address.

"ping -c 5 1.1.1.1"


For more detailed information about how to write systemd-networkd configuration files, refer to the Manual for systemd-networkd, or Octetz.com
Special thanks to Josh Rosso from Octetz.com for his superb guide to creating bridge networks in systemd!

CSS Styling and more from thesitewizard.com