Most of this script is explained in the previous manuals, so I do not bother to explain it here again.
#!/bin/sh PATH=/sbin:/usr/sbin:/usr/local/sbin:/usr/bin:/bin INET_IFACE="eth0" INET_NET=`ip addr show dev $INET_IFACE|grep global|cut -d" " -f6` INET_IP=`echo $INET_NET|cut -d"/" -f1` # vmware HOMENET_IP1="172.16.121.1" HOMENET_IFACE1="vmnet1" echo "Setting iptables rules..." echo 1 >/proc/sys/net/ipv4/ip_forward ############################################################# # CLEAR ALL RULES ############################################################# iptables -F INPUT iptables -F OUTPUT iptables -F FORWARD iptables -t nat -F ############################################################# # DEFAULT POLICIES ############################################################# iptables -P INPUT ACCEPT iptables -P OUTPUT ACCEPT iptables -P FORWARD ACCEPT ############################################################ # IP-MASQUERADING # # http://netfilter.samba.org/ # ############################################################ # iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE iptables -t nat -A POSTROUTING -o $INET_IFACE -j SNAT --to-source $INET_IP iptables -A FORWARD -i $HOMENET_IFACE1 -j ACCEPT iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT # local interface, local machines, going anywhere is valid # (nfs and samba don't work without this rule) # iptables -A INPUT -i $HOMENET_IFACE1 -j ACCEPT echo "Done."All of these manuals/tutorials are provided as is. They worked for me and that is all the help I give with them, so if I forgot something or there is a typo you can inform me but do not expect me to solve your problems :) Oh and almost forgot, use them at your own risk.