Networking

Hardware

Software

Consultation

 

Creating Bridged Interfaces

 
 

Sometimes it's necessary to have multiple network interfaces appear as a single interface to the operating system. I use bridges to help with networking, I can take an underutilized server and add a virtual machine that I can test on my local network without reconfiguring every computer to access a different subnet. It also can simplify firewall creation.

The very first thing we need to do is add the bridging utilities to the system

This entire tutorial requires that you be logged on as root, or a healthy use of the sudo command. I prefer the former. Also, because we will be dealing with the network, it's is best if you are working on the machine locally, or over a serial connection, and not over the network. It can be done just take extra care to get everything correct and save the network restart until the end.
aptitude install bridge-utils

We'll start with a machine that has a single network interface, that we would like to use for virtual machines

One NIC, with DHCP

We are going to be editing the file /etc/network/interfaces so let's back it up first:

cp /etc/network/interfaces{,.`date +%F`.BU}

Now edit /etc/network/interfaces to look like the following:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet dhcp
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

This will do in most cases... For a cursory explanation of the extra parameters see man bridge-utils-interfaces

One NIC, with a Static IP

If you would need the interface to have a static IP address, you would configure the bridge as follows:

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto br0
iface br0 inet static
        address <Static IP>
        network <Local Network>
        netmask <Local Netmask>
        broadcast <Local Broadcast Address>
        gateway <Default Route>
        bridge_ports eth0
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
Multiple NIC's, with DHCP
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual

auto eth2
iface eth2 inet manual

auto br0
iface br0 inet dhcp
        bridge_ports eth0 eth1 eth2
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

In this case I listed all of the interfaces under the bridge_ports parameter, but you can also use the all keyword to use all of the interfaces, like so:

auto br0
iface br0 inet dhcp
        bridge_ports all
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
Multiple NIC's, with a Static IP
# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual

auto eth2
iface eth2 inet manual

auto br0
iface br0 inet static
        address <Static IP>
        network <Local Network>
        netmask <Local Netmask>
        broadcast <Local Broadcast Address>
        gateway <Default Route>
        bridge_ports all
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0
Multiple Bridges, Multiple NIC's, with Static & Dynamic IP's

Finally, if you need multiple bridges on multiple NIC's with Static and Dynamic IP's

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet manual

auto eth1
iface eth1 inet manual

auto eth2
iface eth2 inet manual

auto eth3
iface eth3 inet manual

auto br0
iface br0 inet dhcp
    bridge_ports all

auto br0
iface br0 inet static
        address <Static IP>
        network <Local Network>
        netmask <Local Netmask>
        broadcast <Local Broadcast Address>
        gateway <Default Route>
        bridge_ports eth0 eth1
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

auto br0
iface br0 inet dhcp
        bridge_ports eth2 eth3
        bridge_stp off
        bridge_fd 0
        bridge_maxwait 0

Hopefully that covers enough to get you started...

Add comment


Security code
Refresh