Quick & Dirty KVM?

I’m using caldav/carddav since years to keep my contacts and calendar data always shared across my devices and more important: keep it private.
For the well known reasons, I keep it in a few virtual machines. To have it rather simply I’m using this shell commands (its more a shell script that is executed at server boot time) to configure networking and start the image:

modprobe tun
echo 1 > /proc/sys/net/ipv4/ip_forward
brctl addbr br0
ifconfig br0 10.0.0.6 netmask 255.255.255.248 up
tunctl -b -u root -t qtap0
brctl addif br0 qtap0
ifconfig qtap0 up 0.0.0.0 promisc
route add -host 10.0.0.1 dev br0
iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
6tunnel -6 8443 10.0.0.1 8443
iptables -A PREROUTING -t nat -i eth0 -p tcp –dport 8443 -j DNAT –to 10.0.0.1:8443
qemu-system-x86_64 -enable-kvm -hda cardDAV.qcow2 -m 2048 -net nic,macaddr=52:54:00:12:34:57 -net tap,ifname=qtap0,script=no -vnc none -daemonize

Adding a network bridge, creating an internal private network and configure port forwarding to connect the VM to the outside world.

Leave a comment

Your email address will not be published. Required fields are marked *