############################## DEFINITIONS ##############################

# for local acess to the internet
# NOVIS

EXTIF=ppp1
EXTIP=PUT THE RIGHT IP HERE
EXTGW=`ifconfig $EXTIF |grep "P-t-P" | awk '{ print $3 }' |cut -d ":" -f 2`

# for external acess to servers/vpn
# ONI
SRVIF=ppp0
SRVIP=PUT THE OTHER RIGHT IP HERE
SRVGW=`ifconfig $SRVIF |grep "P-t-P" | awk '{ print $3 }' |cut -d ":" -f 2`

# internal interface
INTIF=eth1

# routing table names

EXTTABLE=novis
SRVTABLE=oni

# servers (server + windows VM)
SERVERS="192.168.1.2 192.168.1.104"

############################## FUNCTIONS ##############################

function forward_service
{
DEST=$1
DPORT=$2
DPORTINT=$3
DPROTO=$4
IF=$5
CMD=-A

if [ $6 = "del" ]; then
	CMD=-D
fi

iptables -t nat $CMD PREROUTING -i $IF -p $DPROTO -m $DPROTO --dport $DPORT -j DNAT --to-destination $DEST:$DPORTINT
iptables -t filter $CMD FORWARD -d $DEST -i $IF -p $DPROTO -m $DPROTO --dport $DPORTINT -j ACCEPT

}


