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".

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`

Edit your interfaces file like this:

sudo vi /etc/network/interfaces

In this case I have a public facing NIC enp0s9 which I do NOT want to bridge.

But I wanted to bridge my internal NIC enp0s8.  The first thing you do is set a line for the bridged NIC to just be manual (remove any IP config info whether static or DHCP from the NIC you want to bridge).

Disable the NIC you want to bridge

iface enp0s8 inet manual

Setup your bridge

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. 

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


iface br0 inet static
  bridge_ports enp0s8

Now of course I could use dhcp instead of static and that is where it would end (assuming you wanted to use DHCP). 

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

Here is what it all looks like:

*Sometimes having the network interface itself creates issues, especially when hacking around trying to make bridging work.  Things work better if you remove any of your NICs from auto.

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

 

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


iface br0 inet static
  bridge_ports enp0s8
   address 192.168.1.1
   netmask 255.255.255.0
   gateway 192.168.1.1

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 br0 br0:0
iface lo inet loopback


iface br0 inet static
  bridge_ports enp0s3
   address 192.168.1.1
   netmask 255.255.255.0
   gateway 192.168.1.1
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 enp0s3 br0
iface lo inet loopback


iface br0 inet static
  bridge_ports enp0s3
   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

 

 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

  • Unable to mount location Failed to retrieve share list from server: Connection timed out - Samba/Linux Filesharing Not working Ubuntu Mint Linux Solution
  • How To Resize, Reduce a Video to a Specific Size and Quality Ubuntu Linux using ffmpeg
  • vi how to delete all lines in the file
  • Linux Mint / Ubuntu 20 Intel I219 NIC disconnects
  • Linux can't boot/grub boot loader screen with no options solution
  • EFI PXE grub2 Howto guide for Linux EFI PXE Booting on Debian, Mint, Ubuntu, RHEL
  • Aruba/HP/Dell IAP Wireless Controller Common Default Passwords
  • Debian, Mint Ubuntu how to remove package and associated config files
  • Linux Grub not booting the intended kernel solution in Debian, Mint, Ubuntu how to specify which kernel to boot by default
  • QEMU KVM Keyboard Problems Not Working Right Repeating Characters, Ctrl+C Copy and Paste not working right when using PS2 mouse in guests Solution
  • Linux how to compile binary with static sharedobjects embedded instead of dynamic to use on multi-distributions and avoid glibc compatiblity issues
  • /bin/sh: msgfmt: not found error solution on Linux Compilation Ubuntu Debian Mint Centos
  • Mikrotik RouterOS CHR/ISO Basic and Quick Setup Howto Guide
  • qemu 4 compilation options
  • CentOS 7 8 PXEBoot Netinstall Not Working Solution "Pane is dead "new value non-exisetnt xfs filesystem is not valid as a default fs type"
  • CentOS 6 EOL yum repo won't work Error: Cannot find a valid baseurl for repo: base Solution
  • CentOS 7 8 How To Disable SELinux
  • Wordpress How To Add Featured Image To Post in Hueman Theme
  • kdenlive full reset how to erase all config files
  • CentOS 7 8 yum error Trying other mirror. To address this issue please refer to the below wiki article