How to: Use iptables for port forwarding

Routers contain a pre-defined port forwarding function that allows you to forwards certain ports to computer or devices on your local network. In most cases, these routers are nothing but computers designed to move data from one port or another. Also, the routers are most likely running a variant of Linux and that the firewall is running iptables. Here’s how you can foward ports to hosts on a Linux machine using iptables.