From: Colin Patrick Mccabe Date: Fri, 1 Jun 2012 18:14:14 +0000 (-0700) Subject: add vbridge.sh script X-Git-Url: http://club.cc.cmu.edu/~cmccabe/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abddbea2f5499968a925deadc581e397aa77d1cf;p=cmccabe-bin add vbridge.sh script Signed-off-by: Colin McCabe --- 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