I have my Raspberry Pi set up so that I can use TightVNC inside my home wireless network with a SSH tunnel. Could someone explain to me how I can access the Pi when I am outside my wireless network range?

As far as I can tell it has something to do with port forwarding the two ports (SSH- 22 and VNC 5901) and maybe setting up a static IP or dynamicDNS but I am not really sure.


1 Answer 1


As far as I can tell it has something to do with port forwarding the two ports

You are correct. In your case, you will need to forward both ports 22 and 5901, as you said. Instructions for doing this vary depending on your router, but the basic process is as follows:

  1. Enter your router's configuration page, and enable port forwarding.
  2. Within your router's port configuration page, set whichever ports you want to be forwarded (22 and 5901, in your case) to be forwarded to your Pi's IP address. To do this you will need your Pi's local IP address, which is (in most cases) automatically assigned by your router via something called DHCP. The issue with this is that if, for example, your Pi is assigned a local IP of today, it may be assigned tomorrow. To ensure that the PI's IP remains constant, you'll have to edit the network configuration file for your distro's network manager. If you're using the Arch Linux image provided on the official site, you'll be using netcfg. Check some of the configuration examples on the Arch wiki for info on how to use a static IP.

  3. Once port forwarding has been set up, SSH into your Pi by using your public IP address and the port specified in step 2. Keep in mind that chances are that your ISP does not supply a static IP to your router/modem, so your public IP may change from day to day.

One final note: If you're tunneling VNC through SSH, then I don't think you'll actually have to forward both ports, as the VNC session will be tunneled through one port through SSH. However, I'm not absolutely sure on this.

  • Thanks, I got it working by just opening the ssh port(22). Is there any security issues that I would need to worry about. I had to use the wireless routers IP address to access the pi but this also changes is there an easy way to set this up (i heard a little about DynDNS).
    – Marmstrong
    Commented May 1, 2013 at 22:35
  • @Marmstrong Obviously, now that you have set up port forwarding, your Pi is now open for the world to access. I would strongly suggest using an SSH key, as this reduces the odds of someone intruding into your system.
    – whjms
    Commented May 1, 2013 at 22:44
  • Point 2: On some routers you can configure the DHCP server to hand out a fixed IP to a computer with a given MAC address.
    – Frepa
    Commented Aug 30, 2013 at 4:41
  • You can also Reserve the IP address for your RPi using its MAC address from inside your Wireless Router's DHCP configuration. Then you won't be needed the static IP address. DHCP will reserve your mentioned IP for your RPi Commented Sep 29, 2013 at 7:51
  • For the people wondering how to tunnel VNC through SSH: raspisimon.dlinkddns.com/tunnelvnc.php Commented Mar 25, 2016 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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