Velvet Star Monitor

Standout celebrity highlights with iconic style.

general

Port forwarding/bypass firewall

Writer Matthew Martinez

I have two servers located at two different places: Ubuntu Server (MySQL) Ubuntu Server (Tomcat)

The problem here is that the Tomcat server cant send data to the mySQL server over port 7878 because it's behind a firewall.

I can SSH to both of the servers. How can I allow the tomcat server behind the firewall to be able to send data to the MySQL with port forwarding/ssh tunnel? I've read about the conecepts but I just can't seem to grasp my head around it, hence me asking for practical help and explanation.

Thank you.

1 Answer

Edit: upon re-reading your question I surmise that your server is behind a firewall that you do not control? If so, please disregard the iptables part of the answer and skip to the SSH config part...

Is it a matter of wanting the transport to be encrypted, or is it simply a matter of getting through the firewall?

Getting through the firewall could be as simple as adding something like:

iptables -A INPUT -i eth0 -p tcp -s --dport 7878 -m state --state NEW,ESTABLISHED -j ACCEPT

If you're looking for a good resource on configuring an SSH connection take a look here:

There's too much to be said on the subject to hash it all out here.

Once you have the basic ssh config set up it should be relatively trivial to create a script to start the connection (including a forwarded port) which could for example be executed when your network interface comes up, similar to the way a lot of people have their iptables rules loaded. Take a look in /etc/network/if-up.d/ (off the top of my head) for examples.

Hope this gets you started!

3

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy