#!/bin/bash NETDEV=$1 # Load the device definition that was written earlier IF_DEF=/var/run/vamos/net/${NETDEV} if [ ! -f ${IF_DEF} ]; then echo >&2 No net device definition found for ${NETDEV} exit 1 fi . ${IF_DEF} # We now have the bridge name as ${BRIDGE} if [ -z "${BRIDGE}" ]; then echo >&2 No bridge device definition found for ${NETDEV} exit 1 fi # Check that the bridge exists and create it if not if ! /usr/sbin/brctl show | sed -e 1d | grep -q ^${BRIDGE}[[:space:]]; then /usr/sbin/brctl addbr ${BRIDGE} if [ "${IP}" ]; then /sbin/ifconfig ${BRIDGE} ${IP} netmask ${MASK} up fi fi # Bring up the interface and connect it to the bridge echo "Connecting interface ${NETDEV} to bridge ${BRIDGE}" /sbin/ifconfig ${NETDEV} 0.0.0.0 promisc up /usr/sbin/brctl addif ${BRIDGE} ${NETDEV}