Tunnel types and how to use it
- Dynamic
- Local
- Remote
Dynamic
I’m in Singapore and let’s say I want to watch Netflix US content.
Sample EnvironmentSingapore
Public IP = 23.51.137.110
Private IP = 192.168.1.23
SSH Server = Disabled
User ID = kevin
Port Forwarded = None US
Public IP = 74.125.200.103
Private IP = 192.168.2.34
SSH Server = Enabled
User ID = ubuntu
Port Forwarded = 22
SSH tunnel command will be like below assuming I wanted to use port 3128
ssh -D 3128 ubuntu@74.125.200.103
Once connected, configure Firefox network settings
I prefer to use Firefox for this because if I were to use Chrome or Safari, then I would have to configure my macOS system preferences. With this my Firefox will be using a US connection.
Local
I have a MySQL DB server in US running at port 3306 but only port 22 is exposed to the internet.
Singapore
Public IP = 23.51.137.110
Private IP = 192.168.1.23
SSH Server = Disabled
User ID = kevin
Port Forwarded = NoneUS
Public IP = 74.125.200.103
Private IP = 192.168.2.34
SSH Server = Enabled
User ID = ubuntu
Port Forwarded = 22
MySQL Server Port = 3306
SSH tunnel command will be like below assuming I am using port 6033 in Singapore to connect to my MySQL server in US running at port 3306
ssh -L 6033:74.125.200.103:3306 ubuntu@74.125.200.103
Once connected you can connect to your MySQL server as though it is running locally in your machine at port 6033.
Remote
Say I have a Ubuntu machine running at home acting as a file server and this machine has internet access but has no ports forwarding to it. I wish to get some files from it in the internet cafe.
Home
Public IP = 23.51.137.110
Private IP = 192.168.1.23
SSH Server = Enabled
User ID = home
Port Forwarded = NoneSingapore
Public IP = 184.29.23.22
Private IP = 192.168.2.34
SSH Server = Enabled
User ID = ubuntu
Port Forwarded = 22Internet Cafe
Public IP = 23.49.29.121
Private IP = 192.168.3.45
SSH Server = Disabled
User ID = cafe
Port Forwarded = None
From the machine at home, a remote tunnel needs to stay connected all the time with the command below to the publicly exposed machine, assuming I’m using port 1234.
ssh -R 1234:127.0.0.1:22 ubuntu@184.29.23.22
From the internet cafe machine, SSH into the publicly accessible Singapore SSH server. From within the server SSH locally using port 1234.
ssh ubuntu@184.29.23.22
Then from within the machine run
ssh -p 1234 home@127.0.0.1
If the machine connecting remotely is a MacOS and the idle SSH connection disconnects frequently. Try adding these into ~/.ssh/config
Host *
ServerAliveInterval 30
ServerAliveCountMax 2