1

I have a script that tries to connect to a remote mysql server and I want to modify the vm it runs in so that instead of the remote ip, the connection will be forwarded to localhost. Can anybody tell me if that's doable, and how?

I do have an it background but networking is sort of a black box for me... I found some examples using iptables but it was almost exclusively for rerouting local connections to remote servers, so the other way round and simply using them with my local and remote IPs and ports didn't work.

[EDIT] The script is doing the right thing on test and production environments but getting it to handle dev environments, too, would involve extra work that I would like to work my way around. It is a possibility, though.

3
  • Why not modify the script instead?
    – atmosx
    Jul 23, 2013 at 9:38
  • see my edit above Jul 23, 2013 at 10:19
  • it's a pity you can downvote someone without having to comment on the reason why... Jul 23, 2013 at 10:38

1 Answer 1

1

Never tested, but according to http://straylink.wordpress.com/2006/08/16/using-iptables-to-redirect-packets , you can use iptables like this :

iptables -t nat -A PREROUTING -p tcp -d 111.222.333.444 --dport 3306 -j REDIRECT --to-ports 3306

1
  • works! That post really fit my situation. Thanks!! Jul 23, 2013 at 12:24

You must log in to answer this question.

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