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.

1 Answers1

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