How To Set up Network Bridge on Ubuntu 22.04

This guide intends to teach you How To Set up Network Bridge or Create Bridge on Ubuntu 22.04.

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.

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 Set up Network Bridge on Ubuntu 22.04

To complete this guide, you must log in to your server as a non-root user with sudo privileges. To do this, you can follow our guide on Initial Server Setup with Ubuntu 22.04.

Install bridge-utils on Ubuntu 22.04

First, you need to update your local package index with the command below:

sudo apt update

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

sudo apt install bridge-utils

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

Network Config on Ubuntu

At this point, I recommend dropping a brand new config in /etc/network/interface.d/ directory.

First, find out your physical interface with the command below:

ip -f inet a s
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 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.

Create Bridge on Ubuntu 22.04

Now create a file for your bridge on Ubuntu 22.04 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
	# If the resolvconf package is installed, you should not edit 
        # the resolv.conf configuration file manually. Set name server here
        # 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 Ubuntu 22.04, add the following content instead :

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

Restart Network

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

Ubuntu 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


At this point, you have learned to Set up a Network bridge on Ubuntu 22.04.

Hope you enjoy it.

You may be like these articles:

How To Restart Network on Ubuntu

List Installed Packages on Ubuntu

Manage Networking with Netplan on Debian / Ubuntu

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!