Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got a linux (ubuntu) computer at work from where I can connect to an external mysql server (not on company NAT). I've also got a laptop from which I want to connect to the mysql server but outside the work network.

How can I setup iptables or ssh port forwarding on my workstation so that it forwards connections to it (from my laptop at home) to the external mysql server?

share|improve this question
up vote 2 down vote accepted

If you can ssh into your work computer do this on your home computer:

ssh -L 3306:mysqlserver:3306 user@workcomputer

and to connect to mysql, run this on your home computer:

mysql -h localhost

This forwards your local port 3306 off to the mysql server that your work computer can connect to.

share|improve this answer
I removed the comment where I said that this was not what I wanted because it was exactly what I wanted I just didn't understand it. Works great, thanks! – Marlun Apr 8 '11 at 12:47

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.