Port Redirection with Windows

Today I have been asked for a copy of a discontinued port-forwarding and proxy tool I have been once recommending. Unfortunately the program page did disappear quite a few years ago and I was not able to find that tool (bouncer from r00ted.co.uk) in my backup files.

After poking a few minutes at google I came across a Port of "rinetd" which I use a lot on my linux boxes: http://www.boutell.com/rinetd/ - a very simple daemon for port redirections. Just feed it with a config file like this:

  1. #bindaddress bindport connectaddress connectport
  2. 192.168.1.145 80 192.168.1.254 8080

Obviously, the config above will redirect all traffic arriving at the "192.168.1.145:80" to "192.168.1.254:8080". Unlike the bouncer tool, rinetd can handle more than one redirection per process. You can define as many forwarding rules in that config as you like.

Last but not least, I have made a tiny change to the source by altering the default location of the config file. Hardcoded location was "/etc/rinetd.conf" which does not make much sense on windows. The attached binary will look for the rinetd.conf next to the executable itself. I have also provided a sample config for that matter:

Comments

By defaults

User defined conf location:
rinetd.exe --conf-file rinetd.conf

Options:
rinetd.exe --help

Works with domains?

Hi,

Does this software works with domains?

Example:

My router forwards all port 80 to a PC.

The PC has SVN server on port 8081 and JBoss on port 8080.

I want to redirect "www.site.com:80" to port 8080, and "svn.site.com:80" to port 8081.

Is it possible?

Thanks

pulsar's picture

nope

That cannot be implemented on that level. There is no concept of "requested domain" from the perspecitve of a TCP packet. Perhaps you got this Idea from Apache's virtual host functionality. Unlike a HTTP request made to the Apache server a TCP packet does not contain any headers which would indicate what FQN / Domain name it was sent to.

So, even though it would be a really cool feature - there is no way to implement that without without doing packet inspection (trying to guess the protocol, analyzing possible request headers).

Here is what you can do though:

- forward :80 traffic to your PC:80
- PC:80 will run Apache2
- Define Virtual Hosts for each "endpoint" (SVN and JBoss)
- Use mod_proxy in conjunction with the corresponding virtual host to redirect traffic to the JBoss Server. Sample config:
  1. NameVirtualHost *
  2. <VirtualHost :80>
  3. ServerName www.site.com
  4. ProxyPass / http://localhost:8080/
  5. ProxyPassReverse / http://localhost:8080/
  6. </VirtualHost>
  7. <VirtualHost :80>
  8. ServerName svn.site.com
  9. DAV-SVN MAGIC GOES HERE
  10. </VirtualHost>

simple config maker for rinetd

I made s simple config editor for rinetd just for fun:
http://www.mediafire.com/?0bykajlhivx

Feel free to use it if you want. :)