How to configure a Linux bridge interface

In computer networking, a bridge is a network device that connects more than one LAN segment at Layer-2. Bridges can filter traffic between different segments, thereby reducing the amount of traffic on LAN, even with many LAN segments. Linux has software bridge functionality built into kernel.

In this post, I will describe how to configure a Linux bridge interface.

Linux bridge setup can be done with a user-space command-line tool called brctl which allows you to create, remove and administer Linux Ethernet bridges.

To use brctl command, you need to install the following package.

On Ubuntu or Debian:

$ sudo apt-get install bridge-utils

On CentOS, RHEL and Fedora:

$ sudo yum install bridge-utils

The brctl command howto

To create a bridge:

$ sudo brctl addbr br0

To remove a bridge:

$ sudo brctl delbr br0

To add an interface to a bridge:

$ sudo brctl addif br0 eth0

To remove an interface to a bridge:

$ sudo brctl delif br0 eth0

It is worthwhile to note that Linux bridge setup created by brctl is NOT persistent, meaning that any bridge created by brctl will automatically be destroyed upon boot. If you would like to have a permanent bridge configuration, you need to use a separate configuration file in /etc.

In the following, I will describe how to create a permanent Linux bridge interface. As an example, I will create a Linux bridge called br100, and add eth0 interface to the bridge. Note that when you enslave a physical interface eth0 into a bridge interface br0, the bridge interface takes over the IP address of the enslaved interface eth0.

Configure a permanent bridge interface on Ubuntu or Debian

You need to edit /etc/network/interfaces. First, remove eth0 configuration from /etc/network/interface, and add the following.

If eth0 has an IP address assigned by DHCP:

auto br100

iface br100 inet dhcp
    bridge_ports      eth0
    bridge_stp        off
    bridge_maxwait    0
    bridge_fd         0

If eth0 has a static IP address:

iface br100 inet static
    bridge_ports      eth0
    bridge_stp        off
    bridge_maxwait    0
    bridge_fd         0
    address <static_IP_address_of_eth0>
    netmask <netmask>
    gateway <gateway>

Configure a permanent bridge interface on CentOS, RHEL or Fedora

You need to update existing eth0 configuration in /etc/sysconfig/network-scripts/ifcfg-eth0, and add bridge configuration in /etc/sysconfig/network-scripts/ifcfg-br100.

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-eth0

If eth0 has an IP address assigned by DHCP:

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-br100

If eth0 has a static IP address:

$ sudo vi /etc/sysconfig/network-scripts/ifcfg-br100

Another way to configure a Linux bridge is via Network Manager. Refer to this tutorial for the detail.

Download this article as ad-free PDF (made possible by your kind donation): 
Download PDF

Subscribe to Xmodulo

Do you want to receive Linux FAQs, detailed tutorials and tips published at Xmodulo? Enter your email address below, and we will deliver our Linux posts straight to your email box, for free. Delivery powered by Google Feedburner.

Support Xmodulo

Did you find this tutorial helpful? Then please be generous and support Xmodulo!

The following two tabs change content below.
Dan Nanni is the founder and also a regular contributor of He is a Linux/FOSS enthusiast who loves to get his hands dirty with his Linux box. He likes to procrastinate when he is supposed to be busy and productive. When he is otherwise free, he likes to watch movies and shop for the coolest gadgets.

2 thoughts on “How to configure a Linux bridge interface

  1. Great job putting together a concise and informative article. I followed it to setup a bridge on a Linux Mint laptop between eth0 and a plugin USB ethernet device (eth1). It worked perfectly the first time.

  2. Hi Dan,

    I am setting up Xen on Ubuntu. I have setup a static Linux bridge on Xen/Dom0 and now need to create a DomU and have that VM's independent ethernet i/f be able to reach the network via Dom0's bridge. how do I do that configuration? Your example (and others I've found) all talk about adding another interface belonging to the bridge owner, and the blogs I've seen discussing this network bridging all assume dhcp. Unfortunately I have a pool of static addresses I must work with, and I haven't found examples of how to statically connect to a bridge from another machine sharing the same lan.


Leave a comment

Your email address will not be published. Required fields are marked *