I was looking for a port forwarding utility that I can use on a Solaris box yesterday. By searching the Internet, I found the portfwd which is a C++ utility. I downloaded to find out it didn't like my 4.x GCC. Figuring it might cost me more time and effort to rebuild an old version of GCC (without root permission), I decide to write a Java version myself so I can reuse it in other OS platforms in future.
I'm done and it is working very well. It listens on a given port and forward all connection to a destination. The port number and destination are specified in command line. I believe this utility is very useful to setup port forwarding in ad hoc basis. I have it in my USB flash drive so I can start forwarding in anywhere that Java goes.
I have file up for download at Google Code. If you do download and find it is useful, please leave a comment here so that I know somebody is using it. To start forwarding, unzip the downloaded zip file to get two jar files and do:
C:\>java -classpath commons-logging.jar;portforward.jar org.enterprisepower.net.portforward.Forwarder 8080 search.yahoo.com:80
Sep 18, 2008 1:11:14 AM org.enterprisepower.net.portforward.Listener <init>
INFO: Ready to accept client connection on 0.0.0.0:8080
Now, launch your browser and point to http://localhost:8080/ you should get the yahoo search page.
Update (9/8/2013): Source code is now at https://github.com/kennethxu/portforward, happy cloning.
Update (4/19/2009): Since I got a lot of request asking for the source code, I decided to have the source available in
Google Code . Feel free to get it from the Subversion repository.