Created
December 4, 2011 11:06
-
-
Save ericliang/1429910 to your computer and use it in GitHub Desktop.
An umbrella script for start up qemu with bridge network support
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
ifconfig wlan0 down | |
# set up a tap interface for qemu | |
# USERID - uid qemu is being run under. | |
USERID=`whoami` | |
iface=`tunctl -b -u $USERID` | |
# generate a random mac address for the qemu nic | |
# shell script borrowed from user pheldens @ qemu forum | |
ranmac=$(echo -n DE:AD:BE:EF ; for i in `seq 1 2` ; \ | |
do echo -n `echo ":$RANDOM$RANDOM" | cut -n -c -3` ;done) | |
echo "using mac address: "$ranmac | |
# specify which NIC to use - see qemu.org for others | |
model=rtl8139 | |
# model=ne2k_isa | |
# start qemu with our parameters | |
qemu-system-x86_64 $@ -net nic,vlan=0,macaddr=$ranmac,model=$model \ | |
-net tap,vlan=0,ifname=$iface | |
# qemu has stopped - no longer using tap interface | |
tunctl -d $iface &> /dev/null | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment