Created
February 26, 2016 11:36
-
-
Save fisher/4af438a0494d31bc112c to your computer and use it in GitHub Desktop.
script to run VM with custom networking
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/sh | |
NAME=`basename -s .sh $0` | |
IMG="${NAME}.img" | |
IFNAME="${NAME}0if" | |
MAC="52:54:00:`echo $NAME |md5sum |perl -ne 's/^(..)(..)(..).*$/$1:$2:$3/; print $_'`" | |
OPTS="-enable-kvm -no-fd-bootchk -name ${NAME} -smp 8,cores=4,sockets=2 -m 1024" | |
NET="-net nic, macaddr=${MAC},vlan=3 -net tap,vlan=3,ifname=${IFNAME},script=no" | |
sudo ip tuntap add name $IFNAME mode tap | |
sudo brctl addif br0 $IFNAME | |
sudo ip link set $IFNAME up | |
#qemu-system-x86_64 -boot c -enable-kvm -m 1024 -cdrom /home/fisher/Downloads/ISO/debian-8.3.0-amd64-netinst.iso -hda deb-jessie.img -netdev user,id=network0 -device e1000,netdev=network0 | |
qemu-system-x86_64 $OPTS -hda $IMG -boot c $NET | |
sudo ip link set $IFNAME down | |
sudo brctl delif br0 $IFNAME | |
sudo ip tuntap del name $IFNAME mode tap |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment