Simple Python script to forward a local port to a remote port. It is better to use firewall rules for forwarding ports, but that is not always possible. One use for this script is to forward ports across local private networks. For example, if you have a Docker container that (indirectly) has a socket bound to port 127.0.0.1:12345 on the local host, you will be able to reach it from machines on your private 192.168.2.0/24 network (assuming the host address on the private network is 192.168.2.1) by running the following command on the host:
./port_forwarding -l 192.168.2.1:12345 -r 127.0.0.1:12345