Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running a Windows Server 2008 R2 machine and was curious on if there is any software out there that would allow me to open port 3307 and route any data sent to it to port 3306. For example, if I'm connecting from a network that blocks the outbound port 3306, is there anything that will allow me to connect to port 3307 and locally (On the Windows Machine) re-route the data to the local 3306 port? On a side-note, this is for a MySQL server. Thanks!

share|improve this question
Why not change the port used by MySQL? Note that your network admins might start hating you if you do this, because they probably have a good reason for this policy. – Daniel Beck May 17 '12 at 15:17
I would do that, but if I did do that I'd have to change all the connection info for websites, programs, etc... – scjosh May 17 '12 at 15:25
If you have a Linux system somewhere outside the restricted network, look into SSH tunneling. – Daniel Beck May 17 '12 at 15:28
up vote 0 down vote accepted

You can use socat for this. There is a Windows port based on Cygwin.

The examples section has this

socat -d -d -lmlocal2 \
TCP4-LISTEN:80,bind=myaddr1,su=nobody,fork,range=,reuseaddr \,bind=myaddr2

TCP port forwarder, each side bound to another local IP address (bind). This example handles an almost arbitrary number of parallel or consecutive connections by fork'ing a new process after each accept() . It provides a little security by su'ing to user nobody after forking; it only permits connections from the private 10 network (range); due to reuseaddr, it allows immediate restart after master process's termination, even if some child sockets are not completely shut down. With -lmlocal2, socat logs to stderr until successfully reaching the accept loop. Further logging is directed to syslog with facility local2.

Although this example is for port 80 (HTTP) you can use socat to create a bidirectional relay for almost any protocol.

You'll notice it shows it's Linux/Unix origins. I don't know how well The Windows port works on Windows or whether some of the options are unsuitable for Windows. I'd give it a try.

For a production system I'd try

  • getting MySQL to listen on multiple port numbers (not currently possible)
  • use port translation in a router?
  • Using socat on a Linux box to relay with port translation. And TEST TO DESTRUCTION.


share|improve this answer
Thanks for this, I'm already used to Linux so this should hopefully be easy to setup :) – scjosh May 18 '12 at 1:23

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .