Code Sample |
#!/bin/sh sudo ifconfig eth0 192.168.0.254 netmask 255.255.255.0 up sudo ifup eth1 # Delete and flush. Default table is "filter". Others like "nat" must be explicitly stated. # - Flush all the rules in filter and nat tables iptables --flush iptables --table nat --flush # - Delete all chains that are not in default filter and nat table iptables --delete-chain iptables --table nat --delete-chain # Set up IP FORWARDing and Masquerading iptables --table nat --append POSTROUTING --out-interface eth1 -j MASQUERADE iptables --append FORWARD --in-interface eth0 -j ACCEPT # - Enables packet forwarding by kernel echo 1 > /proc/sys/net/ipv4/ip_forward |