#!/bin/sh

## Setup your guest OS with the following parameters
## IP - 192.168.1.1
## Mask - 255.255.255.0
## Gateway - 192.168.1.254
## DNS - whatver is in your resolv.conf

# Remember to have the following in sysctl.conf and do sysctl -p
# net.ipv4.ip_forward = 1

# Set these to the IP/mask you want to your qemu vm to have on the network
qemu_ip="152.78.192.217"
qemu_netmask="255.255.252.0"

# Setup an interface for the vm to use
ifconfig eth0:1 up $qemu_ip netmask $qemu_netmask

# Clear iptables
iptables -t nat -F PREROUTING
iptables -t nat -F POSTROUTING

# Setup NAT
iptables -t nat -A PREROUTING -d $qemu_ip \
	-j DNAT --to-destination 192.168.1.1
iptables -t nat -A POSTROUTING -s 192.168.1.1 \
	-j SNAT --to-source $qemu_ip

# Bring up the TUN interface
exec /sbin/ifconfig $1 192.168.1.254
