Configure Debian 10 Linux as Network Bridge

DiegsDiegs
3 min read

Requirements:

  • Install bridge-utils package.

  • Two or more network interface cards.

Configuration:

  • Create a bridge interface.

  • Add physical interfaces to the bridge interface.

  • Restart network interfaces.


Open a terminal and download the package using the command:

# apt update ; apt install bridge-utils -y

After installing the package, edit the file /etc/network/interfaces by your favorite text editor either nano or vi, your choice.

# nano /etc/network/interfaces

# 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

# The primary network interface
allow-hotplug enp0s3
iface enp0s3 inet dhcp
# This is an autoconfigured IPv6 interface
iface enp0s3 inet6 auto

We need to change the network name which is from enp0s3 to ens3 in my case, if you are unsure of what is the name of your interface, type the command # ip address show which will show your current network interfaces.

Also, make sure to add the physical interfaces on your Linux machine.

network interface information shown after using the command # ip addr show

The configuration should look like this if you have three (3) network interface cards:

# 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

# The slave network interfaces
allow hot-plug ens3
iface ens3 inet manual
    pre-up    ifconfig    $IFACE up
    pre-down  ifconfig    $IFACE down

allow hot-plug ens4
iface ens4 inet manual
    pre-up    ifconfig    $IFACE up
    pre-down  ifconfig    $IFACE down

allow hot-plug ens5
iface ens5 inet manual
    pre-up    ifconfig    $IFACE up
    pre-down  ifconfig    $IFACE down

# Bridge interface
auto br0
iface br0 inet static
address 10.10.0.2/24
gateway 10.10.0.1
    bridge_ports ens3 ens4 ens5

# This is an autoconfigured IPv6 interface
iface enp0s3 inet6 auto

What's going on here is that we are saying we want our three network interfaces to be a slave network interface for the bridge interface we also created which is br0

To restart network interfaces use the command:

# systemctl restart networking

As you can see br0 is added as the master interface for the three slave interfaces which are ens3, ens4 and ens5.

Sample topology on gns3

This is a static network where I also used a Debian as a router, which I will also blog about in the next coming blog post a Debian NAT router.

Now, you know how to make your existing Linux old machine into a useful bridge/switch, have fun and good luck. ;)

0
Subscribe to my newsletter

Read articles from Diegs directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Diegs
Diegs

Network Systems Student