Iptables redirect internal port - remote mysql

grzeg

Member
Jul 8, 2004
7
0
151
Hi there!

I'm trying to set up remote mysql server, and got stuck.
All my clients are using "localhost" as mysql address ( mysql_connect('localhost', 'user', 'pass'); ).

New mysql server address would be sql.domain.com, so how am I supposed to redirect all "localhost" connections to "sql.domain.com" ?

I've tried some iptables rules, but couldn't find the right one.

Is there any solution or should I ask all my clients to change their mysql address?

I will be grateful for help!
Best Regards
 

chirpy

Well-Known Member
Verifed Vendor
Jun 15, 2002
13,465
31
473
Go on, have a guess
It would be much better to have the clients change the address as anything else could have unforeseen consequences. If you really want to do it in iptables then you'd need to look at the REDIRECT or DNAT modules in the iptables PREROUTING nat chain.