Basic network bridge configuration for a laptop running Debian


In many different situations, mainly related to virtualization or containers, a basic linux bridge configuration is needed, typically defining br0 connected to the first Ethernet interface, eth0 (no, I don’t like predictable network interface names ;) ). In such a case, a basic configuration of “/etc/network/interfaces” must be similar to:

auto lo 
iface lo inet loopback

iface eth0 inet manual

auto br0
iface br0 inet dhcp
  bridge_ports eth0

But in a laptop, this configuration can slow down the bootup when the network interface is not plugged in, because the “auto br0” statement is ordering the
bridge to always be raised up . This small trouble can be easily solved replacing “auto br0” with “allow-hotplug br0”:

auto lo 
iface lo inet loopback

iface eth0 inet manual

allow-hotplug br0
iface br0 inet dhcp
  bridge_ports eth0

Bridge-utils now provides hotplug capabilities but you must make sure they are enabled in the file “/etc/default/bridge-utils”:

...
BRIDGE_HOTPLUG=yes

With this configuration, when the Ethernet card is connected to the network during the bootup, br0 and eth0 are both raised up, while that doesn’t happen when they’re not connected. In such a case, you can always raise up the bridge manually with ifup when needed:

ifup br0

Additional bridge

It can be also useful on other cases to define a second bridge for internal connections, a bridge not connected to any external network. In such a case and assuming that we always want the bridge br1 to be raised up, the following stanza can be used in “/etc/network/interfaces”:

auto br1
iface br1 inet static
        pre-up ip link add name br1 type bridge
        pre-up ip link set br1 up
        address 10.0.0.1/24

Note that we’re using a static IP address in this case because initially there’s no DHCP server on this network.

Anuncios

, , , ,

  1. Deja un comentario

Responder

Introduce tus datos o haz clic en un icono para iniciar sesión:

Logo de WordPress.com

Estás comentando usando tu cuenta de WordPress.com. Cerrar sesión / Cambiar )

Imagen de Twitter

Estás comentando usando tu cuenta de Twitter. Cerrar sesión / Cambiar )

Foto de Facebook

Estás comentando usando tu cuenta de Facebook. Cerrar sesión / Cambiar )

Google+ photo

Estás comentando usando tu cuenta de Google+. Cerrar sesión / Cambiar )

Conectando a %s

A %d blogueros les gusta esto: