#!/bin/sh

WAN_DEV=ppp10
#WAN_IP=192.168.8.190
WAN_IP=192.168.6.126
LAN_DEV=eth1
LAN_IP=172.22.11.1
FTU_IP=172.22.11.175

iptables -F -t nat
iptables -X -t nat
iptables -Z -t nat
iptables -F -t filter
iptables -X -t filter
iptables -Z -t filter
iptables -F -t mangle
iptables -X -t mangle
iptables -Z -t mangle


iptables -t nat -P POSTROUTING ACCEPT
iptables -t nat -P PREROUTING ACCEPT
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD ACCEPT


iptables -t nat -A PREROUTING -p tcp -d $WAN_IP -j DNAT --to-destination $FTU_IP
iptables -t nat -A PREROUTING -p tcp -d $LAN_IP --dport 22 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d $LAN_IP --dport 23 -j ACCEPT
iptables -t nat -A PREROUTING -p tcp -d $LAN_IP --dport 80 -j ACCEPT
iptables -t nat -A POSTROUTING -o $WAN_DEV -j MASQUERADE
iptables -t nat -A POSTROUTING -s $LAN_IP/24 -o ppp10 -j SNAT --to-source $WAN_I

iptables -A FORWARD -i $LAN_DEV -o $WAN_DEV -m state --state ESTABLISHED,RELATED


echo 1 > /proc/sys/net/ipv4/ip_dynaddr
echo 1 > /proc/sys/net/ipv4/ip_forward