Tatva-Artha

meaning of "it"

Reverse Tunneling and mysql

without comments

Recently, I needed my app in staging to use my local database. Since staging server was on a different network that didn’t have access to my local machine (DMZ), I had to use ssh tunnelling. Here is how I did it:

I setup reverse tunnel that allowed mysql connection from staging server to my local database:

ssh -R 33306:localhost:3306 staging_server

This setup reverse ssh tunnel that allowed anybody trying to connecting to msyql server on staging_server at port 33306 to be routed to mysql server running on my local machine on default port (3306).

With this, I was able to do following on remote server:

mysql -h 127.0.0.1 -P 33306 -u root -p

This comment is trying to connect to mysql on port 33306 on localhost which is getting tunneled to mysql server on my local machine. In the above command, “-h 127.0.0.1″ is required since otherwise mysql will try to connect to “localhost” using /tmp/mysql.sock (socket connection). Also, firewall on staging_server prevented any incoming connection for port 33306, so I couldn’t use “-h 192.168.84.70″ which was the real IP of staging server. Instead, I had to use 127.0.0.1.

Nothing earth-shaking, just a few quirks when getting reverse tunnelling to work.

http://www.tatvartha.com/wp-content/plugins/sociofluid/images/digg_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/reddit_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/stumbleupon_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/delicious_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/google_16.png http://www.tatvartha.com/wp-content/plugins/sociofluid/images/twitter_16.png

No related posts.

Related posts brought to you by Yet Another Related Posts Plugin.

Written by Sharad

September 23rd, 2009 at 10:02 pm

Posted in All

Leave a Reply