I'm trying to tunnel a specific port through my server but I'm not sure where to start or if SSH is the right thing to use.

My current situation is this:

  1. There's a media server at http://example.com:3535 (not a real domain)
  2. Access to that domain is blocked on the network.
  3. I have a VPS in London running OpenVPN and if I connect to that then I can access anything at http://example.com
  4. I don't want to open my VPN up to other people so that they too can access Monkeysplat.com - who knows what people get up to in their own time. I don't want to be involved!

Can I use a spare domain name I have to route traffic to example.com via my VPS? Thus bypassing the network block as it appears they're just connected to my VPS.

If so - how? My VPS is running Ubuntu 14.04 if that helps.

  • 1
    And where does SSH get into all of this?
    – Bananguin
    Aug 13, 2017 at 20:29

3 Answers 3


ssh -L 3535:example.com:3535 -p port you@your.vps.com (*) would allow you to connect to example.com:3535 through the port 3535 on localhost. No need for an additional domain name, you can connect to your VPS by just using its IP address.

(*) no real domains

  • Ok so this works, I can access the example.com service by going to localhost:3535. How do I enable others to access the tunnel now? Aug 13, 2017 at 22:44
  • For security reasons, the port 3535 is only accessible to localhost by default. You can have your ssh daemon listening on other interfaces than lobut it requires some configuration changes to sshd. See the GatewayPorts option.
    – xhienne
    Aug 13, 2017 at 23:05

You need neither SSH (because you already have the VPN) nor DNS: It helps a lot if the VPN endpoint knows who you are trying to talk to...

You need routing. Si if example.com is and your VPN peer address is then you change your routing table like this (which can be integrated into the OpebVPN config):

ip route add via

I did setup a tunnel with the help of this article http://www.thegeekstuff.com/2013/11/reverse-ssh-tunnel

Here is the command your friend sitting on remote server side should run on the server :

ssh -fN -R 7000:localhost:22 username@yourMachine-ipaddress

So this ssh connection request originating from remote server to your machine will make sure that any ssh connection request for port 7000 on your machine is forwarded to port 22 of remote server.

Now do an ssh connection request from your machine to your own machine at port 7000:

ssh username@localhost -p 7000


Your Answer

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

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