Debian Ubuntu Mint Howto Create Bridge (br0)

Having a network bridge allows you to bridge traffic under multiple devices so they can talk natively without using any special routing, iptables/firewall or other trickery.

To create your bridge you need the bridge-utils package for brctl and if you want to do things like bridge VMs that run on a tap   device you will need the uml-utilities which provides "tunctl".

1.) Install the utilities to make our bridge

sudo apt-get install bridge-utils uml-utilities

Backup your interfaces file to your home dir

sudo cp /etc/network/interfaces ~/interfaces-`date +%Y-%m-%d-%s`

 

2.) Setup your bridge by editing /etc/network/interfaces

Also be note that the br0 is a zero not an "O"

For simplicity I am going to call it br0 but it could be called almost anything.

Edit your interfaces file like this:


br0 using eth0 and DHCP

#example of NIC named eth0, bridged as eth0 and using DHCP (change eth0 to the name of your NIC) device

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
  bridge_ports eth0


br0 using eth0 and static IP


Be sure to change the static IP, gateway, netmask and bridge_ports to what matches what you need.

#example of NIC named eth0, bridged as eth0 and using static (change eth0 to the name of your NIC) device

auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
  address 192.168.1.200
  netmask 255.255.255.0
  gateway 192.168.1.1
  bridge_ports eth0

 


The key part is below in bold where I declare the br0:


iface br0 inet static
  bridge_ports enp0s8

The above part tells us that we are bridging a NC named enp0s8.

On the second line below indented you add "bridge_ports enp0s8" which defines enp0s8 as belonging to the br0 bridge.

*Note what you see below are NOT commands in the terminal but the contents of /etc/network/interfaces

eg. iface is NOT a command, it is part of the config file /etc/network/interfaces

**Note change enp0s8 to your NIC adapter that you want to bridge.

 


Another basic example of what it could look like if you wanted a static IP and to receive a DHCP on your bridge:


# interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
  bridge_ports eth0
   address 192.168.1.1
   netmask 255.255.255.0
   gateway 192.168.1.1

auto br0:0
iface br0:0 inet dhcp

 


Example of adding an alias to the bridge


 # interfaces(5) file used by ifup(8) and ifdown(8)
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual


auto br0
iface br0 inet static
  bridge_ports eth0
   address 192.168.1.1
   netmask 255.255.255.0
   gateway 192.168.1.1
#below we add an alias called br0:0 but we could have called it br0:1, br0:10 etc...
auto br0:0
iface br0:0 inet static
   address 192.168.1.200
   netmask 255.255.255.0
   gateway 192.168.1.1


 

After you are done do not forget to restart your network to apply the changes or your bridge won't work.

sudo service networking restart

 

Manual Quick and dirty (temporary) to get a bridge up and running:

Note that this is temporary so once you restart your network or your server the bridge will no longer be there or working:

#create a bridge named br0

sudo brctl addbr br0

#add a NIC named eno1 to br0 bridge
sudo brctl addif br0 eno1

# put our bridge up or it won't work
sudo ifconfig br0 up

# bring your NIC down and then back up otherwise the bridge won't work
sudo ifconfig eno1 down
sudo ifconfig eno1 0.0.0.0 up

#use dhclient on interface br0 to get a LAN IP by DHCP

#if you are using static then you would set the IP statically / manually
sudo dhclient  -i br0


Tags:

debian, ubuntu, mint, howto, br, allows, multiple, devices, natively, routing, iptables, firewall, trickery, utils, brctl, vms, uml, utilities, provides, quot, tunctl, install, sudo, apt, interfaces, dir, cp, etc, edit, nic, enp, bridged, manual, ip, config, info, static, dhcp, disable, iface, inet, simplicity, bold, declare, bridge_ports, indented, defines, belonging, ifup, ifdown, auto, loopback, netmask, gateway,

Latest Articles

  • How To Upgrade Debian 8,9,10 to Debian 12 Bookworm
  • Linux dhcp dhclient Mint Redhat Ubuntu Debian How To Use Local Domain DNS Server Instead of ISPs
  • Docker dockerd swarm high CPU usage cause solution
  • Docker Minimum Requirements/How Efficient is Docker? How Much Memory Does Dockerd Use?
  • qemu-nbd: Failed to set NBD socket solution qemu-nbd: Disconnect client, due to: Failed to read request: Unexpected end-of-file before all bytes were read
  • apache2 httpd apache server will not start [pid 22449:tid 139972160445760] AH00052: child pid 23248 exit signal Aborted (6) solution Mint Debian Ubuntu Redhat
  • How to use the FTDI USB serial cable to RJ45 adapter to connect to the console on Cisco/Juniper Switch Router Firewall in Linux Ubuntu Debian Redhat
  • How To Setup Python3 in Ubuntu Docker Image for AI Deep Learning
  • How to Configure NVIDIA GPUs with Docker on Ubuntu: A Comprehensive Guide for AI Deep Learning CUDA Solution
  • Linux Ubuntu Mint how to check nameservers when /etc/resolv.conf disabled solution
  • Docker cannot work on other overlayfs filesystems such as ecryptfs won't start overlayfs: filesystem on '/home/docker/overlay2/check-overlayfs-support130645871/upper' not supported as upperdir
  • Linux How To Access Original Contents of Directory Mounted Debian Mint CentOS Redhat Solution
  • ecryptfs how to manually encrypt your existing home directory or other directory
  • How to Reset CIPC Cisco IP Communicator for CME CUCM CallManager
  • Internet Explorer Cannot Download File "Your security settings do not allow for this file to be downloaded." Security Settings Solution
  • Linux How To Upgrade To The Latest Kernel Debian Mint Ubuntu
  • Firefox how to restore and backup saved passwords and history which files/location
  • Linux How To echo as root solution to use tee permission denied solution Ubuntu Debian Mint Redhat CentOS
  • Linux how to keep command line bash process running if you are disconnected or need to logout of SSH remotely
  • Linux swapping too much? How to check the swappiness and stop swapping