#! /bin/bash
WAN=eth1
LAN=eth0
echo 1 > /proc/sys/net/ipv4/ip_forward
#Flush all old rules
/sbin/iptables -F
/sbin/iptables -t nat -F
#Setup NAT
/sbin/iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
/sbin/iptables -A FORWARD -i eth1 -o eth0 -m state --state RELATED,ESTABLISHED -j ACCEPT
/sbin/iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT
#---------------------------------------------------------------
# Allow port forwarding for traffic destined to port 80 of the
# firewall's IP address to be forwarded to port 80 on server
# 172.26.0.110
#
# - Interface eth0 is the internet interface
# - Interface eth1 is the private network interface
#---------------------------------------------------------------
export IFACE=eth1
EXTERNAL_IP=`ipq`
#Poke hole for HTTP to www
/sbin/iptables -t nat -A PREROUTING -p tcp --dport 80 -i ${WAN} -j DNAT --to 172.26.0.110
/sbin/iptables -t nat -A POSTROUTING -p tcp --dst $EXTERNAL_IP --dport 80 -j SNAT --to-source 172.26.0.110