How To Set up Network bridge on Debian 11

In this article, we want to teach you How To Set up a Network bridge on Debian 11.

A network bridge is a Link Layer device that forwards traffic between networks based on MAC addresses and is therefore also referred to as a Layer 2 device.

It makes forwarding decisions based on tables of MAC addresses which it builds by learning what hosts are connected to each network. A software bridge can be used within a Linux host in order to emulate a hardware bridge.

Steps To Set up Network bridge on Debian 11

Before you start to complete this guide, you need to log in to your server as a non-root user with sudo privileges. To do this, you can follow our article the Initial Server Setup with Debian 11.

If you want to assign IP addresses to your virtual machines and make them accessible from your LAN you need to set up a network bridge. By default, a private network bridge is created when using KVM. You need to set up interfaces manually, avoiding conflicts with, the network manager.

Now follow the steps below to set up a network bridge on Debian 11.

Network bridge on Debian 11

First, you need to install the bridge-utils on Debian 11 with the command below:

sudo apt install bridge-utils

Then, you need to edit the /etc/network/interface file. However, I recommend dropping a brand new config in /etc/network/interface.d/ directory.

Debian Network Config

Find out your physical interface with the command below:

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

eth0 is our 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 vi:

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.

Create Bridge on Debian 11

Now create a file for your bridge on Debian 11 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

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 11, add the following content instead :

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

Now you need to restart the network service on Debian 11. 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

Debian brctl command

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 learn to Set up a Network bridge on Debian 11.

Hope you enjoy it.

You may be like these articles:

Monitor Linux Network Bandwidth Usage with nload Command

How To Configure Networking on AlmaLinux

How To Configure Networking on Rocky Linux

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Leave a Reply

Stay informed and not overwhelmed, subscribe now!