Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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

1 Answer 1

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=10.0.0.0/8,reuseaddr \
TCP4:www.domain.org:80,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.

(Ick)

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.