Port Forwarding On Ubuntu Using iptables

If you need to forward TCP packets then you can do so using iptables - which is a firewall installed in Unbutu.

But why?

I have a Windows PC, installed on premesis. I want to give external users access to this PC, but not directly. They must authenticate from my linux pc, and if successful, I will forward them on.

I have not written the authentication code, but I wanted to test out the concept.

  • When a packet comes in, we must tell it: hey - go to the windows PC.
  • When a packet returns from the windows PC, we must tell it to “go back where you came from” so that nobody is none the wiser. The POSTROUTING SNAT command takes care of that.

Of course, if you restart your PC then you will have to re-run the script.

After proving that the utility of this concept, I will write an authentication script, preventing users from being forwarded onto the windows server, if they do not authenticate.

Written on November 14, 2023