Redirecting TCP ports

Redirecting TCP ports

In a recent attempt of moving an application from one server to another, I needed the MySQL server running on the old server on localhost to listen on another IP address. Digging into the MySQL documentation I realized there's only an all-or-nothing approach built into MySQL server. This means MySQL is only able to listen on one IP address or all IP addresses. Of course, I could have configured MySQL to listen on all IP addresses (networks) and then use a couple of firewall rules to lock access, this seems like a common approach.

However, with a little research on Google I came across a tool called redir which is "a TCP port redirector for UNIX". That sounded exactly like the solution I was looking for ;) Since redir is available as a Debian package, I could simply apt install it. The easiest way of getting it to run, is start it from the command line like this:

redir 10.15.22.11:3306 127.0.0.1:3306


This setup redirects any TCP traffic from port 3306 of 10.15.22.11 to port 3306 exposed on localhost which is the port the MySQL server is listening to. For an improved set-up you can add redir to your xinetd or inetd configuration. And since redir only works for TCP connections, you might want to give uredir a try for redirecting your UDP connections.


Eintrag von Stephan Hochdörfer am 15.03.2018

Tags: Unix, Admin

Diese Webseite verwendet Cookies, um die Bedienfreundlichkeit zu erhöhen. Mit der Nutzung unserer Webseite wird das Einverständnis erklärt, dass wir Cookies verwenden. Weitere Informationen.