Network Bridge Configuration on Debian 12 Linux

This guide intends to teach you to Network Bridge Configuration on Debian 12 Linux. First, we want to describe what is a network bridge and then start network configuration and create a bridge on Debian 12 Bookworm. Please follow the rest of the article.

What is a Network Bridge on Linux?

In simple words, a network bridge is a device that divides a network into segments. Each segment represents a separate collision domain, so the number of collisions on the network is reduced. Each collision domain has its own separate bandwidth, so a bridge also improves the network performance.

How Does Network Bridge Work?

A bridge works at the Data link layer (Layer 2) of the OSI model. It inspects incoming traffic and decides whether to forward it or filter it. Each incoming Ethernet frame is inspected for the destination MAC address. If the bridge determines that the destination host is on another segment of the network, it forwards the frame to that segment.

Steps To Network Bridge Configuration on Debian 12 Linux

To create a network bridge on your Debian 12, you must have access to your server as a non-root user with sudo privileges. To do this, you can follow this guide on Initial Server Setup with Debian 12 Bookworm.

Then, follow the steps below to complete this guide.

Step 1 – Install the bridge-utils package on Debian 12 Linux

First, you must run the system update by using the following command:

sudo apt update

The bridge-utils package contains a utility needed to create and manage bridge devices.

Then, use the following command to install the bridge-utils on Debian 12:

sudo apt install bridge-utils -y

Now you need to make some configuration changes at the /etc/network/interface file.

Step 2 – Edit Network Configuration File on Debian 12

At this point, you must edit the network configuration file on your Debian 12 Linux server.

First, find your physical interface with the command below:

sudo ip -f inet a s
Output
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
inet ... brd ... scope global eth0
valid_lft forever preferred_lft forever

In my case, eth0 is my physical interface.

At this point, you need to be sure that only “lo” (loopback) is active in the /etc/network/ interface.

Open the file with your favorite text editor, here we use the vi editor:

sudo vi /etc/network/interfaces

Remove any config related to eth0 and your config file should be similar to this:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).
 
source /etc/network/interfaces.d/*
 
# The loopback network interface
auto lo
iface lo inet loopback

When you are done, save and close the file.

Step 3 – Create a Bridge on Debian 12

Now create a file for your bridge on Debian 12 with your favorite text editor, here we use vi:

sudo vi /etc/network/interfaces.d/br0

Add the following content to your file:

## static ip config file for br0 ##
auto br0
iface br0 inet static
	address 192.168.2.23
	broadcast 192.168.2.255
	netmask 255.255.255.0
	gateway 192.168.2.254
	# If the resolvconf package is installed, you should not edit 
        # the resolv.conf configuration file manually. Set name server here
        #dns-nameservers 192.168.2.254
        # If you have muliple interfaces such as eth0 and eth1
        # bridge_ports eth0 eth1  
	bridge_ports eth0
	bridge_stp off       # disable Spanning Tree Protocol
        bridge_waitport 0    # no delay before a port becomes available
        bridge_fd 0          # no forwarding delay

Note: Remember to replace the address, broadcast, netmask, gateway, and bridge ports values.

When you are done, save and close the file.

Note: If you want a bridge to get an IP address using DHCP on Debian 12, add the following content to the file instead :

## DHCP ip config file for br0 ##
auto br0
 
# Bridge setup
 iface br0 inet dhcp
    bridge_ports eth0

Step 4 – Restart Network on Debian 12

Now you need to restart the network service. Before you restart the networking service make sure the firewall is disabled.

Use the command below to restart your service:

sudo systemctl restart networking

Then, verify that the service is started:

sudo systemctl status networking

Step 5 – Debian Linux brctl Command

At this point, you can use the brctl command to view info about your bridges:

brctl show

Also, use the command below to show your current bridges:

bridge link

Conclusion

At this point, you have learned what is a network bridge and how it works and learned to install the bridge-utils package on your Debian 12 to create and manage bridge devices.

Hope you enjoy this guide on Network Bridge Configuration on Debian 12 Linux.

Also, you may be interested in these articles too:

Set up Nginx with Brotli Compression on Debian 12 Bookworm

Install Laravel with LAMP Stack on Debian 12 Bookworm

System Locale Setup on Debian 12 Bookworm Command Line

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!