Sunday, March 23, 2008

Simple Port Forwarding using IPTABLES

# IP Forwarding
echo "1" > /proc/sys/net/ipv4/ip_forward

# Policy
/sbin/iptables -P INPUT ACCEPT
/sbin/iptables -P OUTPUT ACCEPT
/sbin/iptables -P FORWARD ACCEPT

# IP Masquerade
/sbin/iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE

# Forward
/sbin/iptables -A FORWARD -i eth0 -j ACCEPT

# Portforwarding from to
/sbin/iptables -t nat -A PREROUTING -p tcp -i eth0 --dport 8888 -j DNAT --to
/sbin/iptables -A FORWARD -p tcp -i eth0 -d --dport 80 -j ACCEPT


Cindy Dy said...

Nice article love to read the whole new way of your writing this things.


Leslie Lim said...

First time I commented in a blog! I really enjoy it. You have an awesome post. Please do more articles like this. I'm gonna come back surely. God bless.