First of all i excuse my following bad english, I'm not a native english speaker so I'll try.

I have my raspbery pi 2 already connected to internet, but I would like to connect to the pi outside my local network. I know that this question has been already asked, but my router show many options that I don't know what to write there.

This show my router to port forward

Also, If I have to configure something more in the Pi, don't doubt in telling it :)

Thanks anyway!

2 Answers 2


I am assuming that you want to connect to the pi via ssh and that ssh is already set up on the pi: so you can connect from the local network.

The Internal IP address is the address of the pi on your local network: you might need to change the pi to use a static IP address. Edit /etc/network/interfaces, remove the line iface eth0 inet dhcp and add these lines:

iface eth0 inet static
address 192.168.0.NNN
gateway 192.168.0.MMM

where NNN is the address you want the pi to have and MMM is the IP address of your gateway.

The Internal Start Port and End Port are both 22.

If you want to connect from any external address, leave the Remote Host Address as all zeros.

The External Start Port and End Port are both 22 (unless you want to use a different port).

The Protocol is TCP.

Tick the "Enabled" box.

With these settings you should be able to access the pi from outside the network using:

ssh [email protected]

where XXX.XXX.XXX.XXX is the external IP address of your gateway: this is the address that the rest of the Internet sees. If you don't know it, just type "my ip" into Google, and Google will tell you what it is!

  • Thanks! I was already connected via ssh to my pi, and changed the /etc/network/interfaces file. I just didn't know what to write in Internal and External Port of my router. But now I have a new question, why would I use a different port in External Start and End Port? BTW really really thanks :)
    – polanks
    Commented Apr 30, 2015 at 16:47
  • If you have more than one internal machine which you want to access from outside via ssh, you can use a different port for each machine. Note that they will all have the same external IP address. Commented May 1, 2015 at 16:57
  • For example, forward port 21 to pi1 and port 22 to pi2. The internal port is 22 in both cases. Then ssh -p 21 [email protected] will connect to pi1 and ssh [email protected] will connect to pi2. Commented May 1, 2015 at 17:03

so to break it down, that first box will be the internal address of your device (so its 192.168.0.____, fill in the blank using the method above). the ports require a bit more info, but the usual method of headless pi access is SSH on 22 and SOMETIMES telnet on port 23, so make them 22 and 22 or 23.

the external address could be for a static point to point connection, but more likely it is for your own external address, the one that your router holds on the internet, so google whats my ip and make a note. (POINT TO REMEMBER - this may and probably will change each time your router turns off/on, most IP addresses are on a DHCP style config, so if it stops working do another "whats my IP") ports need to mirror your internal ones

where it says both, the other options are probably TCP and UDP, you can read up on these in much more detail elsewhere but the odds are your going to want TCP for most of your networking, so go TCP or both. i havent seen a UDP only system in a long time.

lastly, easy one, enabled is just telling your program if this rule is active or not, so you can set up a dozen rules and have them inactive until you need them.

in summary:

internal IP = 192.168.0.XXX (i would do an arp scan to find all IPs on network); ports 22-22 or 22-23 for internal/external ports; remote host = whats my ip result from google; protocol TCP or both; remember to enable!

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.