Duplicate/Reroute port to another port

1

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!

scjosh

Posted 2012-05-17T14:59:26.697

Reputation: 113

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 – 2012-05-17T15:17:24.467

I would do that, but if I did do that I'd have to change all the connection info for websites, programs, etc... – scjosh – 2012-05-17T15:25:15.823

If you have a Linux system somewhere outside the restricted network, look into SSH tunneling. – Daniel Beck – 2012-05-17T15:28:42.770

Answers

0

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)

RedGrittyBrick

Posted 2012-05-17T14:59:26.697

Reputation: 70 632

Thanks for this, I'm already used to Linux so this should hopefully be easy to setup :) – scjosh – 2012-05-18T01:23:11.180