2 # The following script example, if dropped in /etc/network/if-pre-up.d/
3 # and under /etc/network/if-down.d/, will manage to configure a bridge
4 # if defined in the /etc/network/interfaces file as either:
6 # Note: The bridge-utils package already provide a similar (more
7 # powerful) script this is just provided here for convenience and to
8 # show how the /etc/network/if-*.d/ methods can be defined.
10 # [ a bridge with an associated IP address ]
11 # iface br0 inet static
12 # bridge-ifaces eth0 eth1
14 # netmask 255.255.255.0
15 # [ a bridge which acts as an anonymous bridge ]
16 # iface br0 inet manual
17 # bridge-ifaces eth0 eth1
18 # up ifconfig $IFACE up
20 # For more information read:
21 # http://bridge.sourceforge.net/howto.html
25 # Notice that the bridge-utils package must be installed and
26 # we need to have the BRIDGE_IFACES in order to work
27 [ "$IF_BRIDGE_IFACES" = "" ] && exit 0
28 if [ -z "$brctl" ] ; then
29 # ? Somebody is trying to use us without having bridge-utils?
30 echo "Cannot find the 'brctl' program to setup the bridge"
31 echo "Hint: Have you installed the bridge-utils package?"
35 # Check all interfaces before proceeding
36 for i in $IF_BRIDGE_IFACES; do
37 ip link show $i >/dev/null 2>&1
38 if [ $? -ne 0 ] ; then
39 echo "Interface $i is not available, aborting"
44 if [ "$MODE" = "start" ] ; then
45 # We are being called by ifup:
46 # Bring up all the bridge interfaces
47 for i in $IF_BRIDGE_IFACES; do
48 ifconfig $i 0.0.0.0 up
50 # And now add the bridge itself and the interfaces which are part
53 for i in $IF_BRIDGE_IFACES; do
56 elif [ "$MODE" = "stop" ]; then
57 # We are being called by ifdown:
58 # Remove the bridge itself and the bridge association
59 for i in $IF_BRIDGE_IFACES; do
63 # Bring down all the bridge interfaces
64 for i in $IF_BRIDGE_IFACES; do