From abddbea2f5499968a925deadc581e397aa77d1cf Mon Sep 17 00:00:00 2001 From: Colin Patrick Mccabe Date: Fri, 1 Jun 2012 11:14:14 -0700 Subject: [PATCH] add vbridge.sh script Signed-off-by: Colin McCabe --- vbridge.sh | 38 ++++++++++++++++++++++++++++++++++++++ 1 files changed, 38 insertions(+), 0 deletions(-) create mode 100755 vbridge.sh diff --git a/vbridge.sh b/vbridge.sh new file mode 100755 index 0000000..f59ee33 --- /dev/null +++ b/vbridge.sh @@ -0,0 +1,38 @@ +#!/bin/bash -xe + +# +# Create tun and bridge interfaces for qemu. +# + +TAP=tap0 +BR=br0 + +die() { + echo $@ + exit 1 +} + +up() { + /sbin/tunctl -b -t $TAP + /sbin/ifconfig $TAP up + /sbin/brctl addbr $BR + /sbin/brctl addif $BR $TAP + /sbin/ifconfig $BR 192.168.123.1 netmask 255.255.255.0 + /sbin/ifconfig $BR up +} + +down() { + /sbin/ifconfig $BR down + /sbin/ifconfig $TAP down + /sbin/brctl delbr $BR + /sbin/tunctl -d $TAP +} + +ARG="x$1" +if [ $ARG == "xup" ]; then + up +elif [ $ARG == "xdown" ]; then + down +else + die "must specify either up or down." +fi -- 1.6.6.rc1.39.g9a42