# To use iptables-based NAT, we must enable IP forwarding for IPv4:
echo 1 > /proc/sys/net/ipv4/ip_forward
# Or modify /etc/sysctl.conf such that:
# net.ipv4.ip_forward = 1
# IPTABLES firewall
# extdev: the network device/interface for the external network
# intdev: the network device/interface for the internal network
extdev=eth0
intdev=eth1
# extip: the IP of the external network
# intranet: the network ID of the internal network
# Manually assign the value of extip or intranet:
#extip=20.30.40.50
#intranet=192.168.9.0/24
# Or extract the value from output of ifconfig:
extip=`/sbin/ifconfig $extdev | grep inet | cut -d : -f 2 | cut -d ' ' -f 1`
intranet=`/sbin/ifconfig $intdev | grep inet | cut -d : -f 2 | cut -d ' ' -f 1 | cut -d . -f 1-3`.0/24