#!/bin/sh # Licensed to the Apache Software Foundation (ASF) under one # or more contributor license agreements. See the NOTICE file # distributed with this work for additional information # regarding copyright ownership. The ASF licenses this file # to you under the Apache License, Version 2.0 (the # "License"); you may not use this file except in compliance # with the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, # software distributed under the License is distributed on an # "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. # by Richard Gass and Michael Stroucken # Adapt the following two parameters to your installation # Uplink interface UPLINKIF="eth0" # Prefix for bridge naming BRIDGEPREFIX="br" vlanID=$(echo $0 | awk -F "ifup." '{print $2}') vmIf=$1 # see if tagged interface exists bridgeUplinkIf="${UPLINKIF}.${vlanID}" cat /proc/net/vlan/config | grep "${bridgeUplinkIf} " if [ $? -gt 0 ];then echo "creating tagged interface" vconfig add ${UPLINKIF} ${vlanID} ip link set ${bridgeUplinkIf} up fi # Check for the bridge bridgeName="${BRIDGEPREFIX}${vlanID}" brctl show | grep "^${bridgeName}" if [ $? -gt 0 ];then echo "creating bridge interface" brctl addbr ${bridgeName} brctl addif ${bridgeName} ${bridgeUplinkIf} ip link set ${bridgeName} up fi /sbin/ifconfig ${vmIf} 0.0.0.0 up /usr/sbin/brctl addif ${bridgeName} ${vmIf} exit 0