Port forwarding is where you connect to a port on a gateway machine and it automatically forwards you to another port on another machine. It can be useful in a very wide range of situations, including bypassing firewalls or redirecting traffic from a public network to a private network (or vice-versa). Combined with lines in your windows\system32\drivers\etc\hosts file you can even redirect where outgoing connections go.

A number of people have asked me to update my trivial port forwarding utility to be a little more user friendly. This is the result. You can download it here and if you want, here's the code.

Apart from its obvious graphicalness, this version allows you to set up any number of port redirections. You can see how many connections are being redirected and you can disconnect them if you feel the need. You can save the redirections you have setup and load them again later.

If you'd prefer the old command line utility, here's the old source code and windows binary.

usage: trivial_portforward [port to listen on] [ip of host to connect to] [port to connect to].

Note: that's ip address, not host name. If you want host names, add your own dns lookup code or use the fancy graphical version.

QuantumG
<< back to my home page


fed says:
great, thanks
Des says:
so great, mucho thanks!!!

I have a question. How many threads (connections) this module can handle?
And how can I start this as windows service?
KolobocK says:
thanks for code!
but trivial sources and binary are not available :(
also could you please put here header file for portforward.cpp (portforward.h)? [oops, done].
Hector Garcia (hec50@hotmail.com) says:
This program is pretty cool, but I tried to use it over Windows Xp 64 bits and it didnīt work, do you know any other program like this that works over Xp 64 bits? Thanks in advance...
QuantumG says:
I use it on xp64, no problems.
xerces8 says:
The gui version fails on my WinXP 32bit too. The CLI versions works thou
Jon Ashley (jonathan.ashley@ praxis-his.com) says:
That's a really nice little tool! It looks as though it might solve a problem for me. Can you please tell me what licence it is under? Thanks.
Albert Bloomfield says:
I think you should be calling shutdown() in your code somewhere. Anyway it didn't work right for me until I put in some calls to shutdown() before you close the sockets.
Troy says:
is there a way to specify which local ip to use if the system has multiple?
Pedro says:
Around portfoward.cpp:660, function dnslookup(), the line
return (a << 24) | (b << 16) | (c << 8) | d; // network order
I think that should be:
return (d << 24) | (c << 16) | (b << 8) | a;
foo says:
test
thirdwheel says:
Hey, great tool, thanks. One problem though, I have it route requests to a port (say, 8123) to port 22 of a VM (ip address 192.168.0.5) - I can connect to it directly but not through the tunnel entry. It registers the connection but when it tries to connect, it times out. I'm running Windows XP SP2. The VM is attached to an MS Loopback adapter.
thirdwheel says:
I just tried the command line tool, and it worked fine... wtf
thirdwheel says:
Hey, what did you use to compile this? I compiled it using mingw and it came out 18k smaller... and that was with static linking...
thirdwheel says:
hey Troy, I've made a change to the command line version of this program that allows you to specify an IP address. If you have mingw, you can get the patch at http://milo.thats-too-much.info/patches/trivial_portforward-sourceip.patch - GUI version change to come

Your name: