Port forwarding

From Wiki

Jump to: navigation, search


To port Forward general ports from a Linux box to a Windows Client

Problem: MySQL will only allow connections coming from localhost.
Solution: Port Forward port 3306 through a SSH tunnel. Connect to MYSQL on mysql.server.ie

user = steve
pass = usual one

SSH Tunnel: Source port: 3306 Destination: localhost:3306 (Local Port)

On the Windows Client:

mysql -h localhost -u steveb -p
pass = password
Use database

To Port Forward a Windows/ Samba Network share via an Outside Linux Box onto a Windows PC

Tunneling using Putty: In Tunnels Option ->

Source Port:
Destination: 136.x.x.x:139

In an Address Bar or Run box (Windows):


Port Forwarding in Linux

This can also be automated in the ~/..ssh Directory

Has to be tested and confirmed:

ssh -N -L 3333:136.xxx.xxx.xxx:5900 -x skynet.ie

Semi-Long Term Port Forwarding from Windows to Linux

Situation: you can connect to a Linux server on your LAN - however you need to access an external server through this linux server. You want to put a semi-permanent port forwarding in place.

You could use PuTTY using the method above - but putty would have to be open all the time.

Use portforwarding on the local linux server.

Login to the ssh server:

ssh -f -g -L 3221:test.burkesys.com:22 -l username local.linux.pc sleep 600d
// -f = fork into the background
// -g = allow external clients from the LAN connect to 3221
// -L = Local port forward
// -l = username of local linuxpc

telnet local.linux.pc 3221
//try the above on your local windows pc etc. It should connect through on port 3221.

Note if the linux pc has a firewall - it wont work. To see if its working on the local linux pc:

ps -eaf
netstat -na

More Info: http://www.howtoforge.com/nfs_ssh_tunneling

Long Term Port Forwarding using iptables

Not tested yet. I presume NAT will have to be used.

Personal tools