***port forwarding***

I'm trying to forward my port so I can work on my Raspberry from work (through ssh), but I've tried several combinations which won't work.

Could someone explain to me which external/internal ports I should forward? I particularly don't understand which external ports should be forwarded, as I don't know through which port I'll be accessing the network.

  • 1
    Can you ssh into your Pi from another system on your LAN? Nov 8, 2017 at 22:43
  • Have you thought about the security implications and how to mitigate them? If not this is a really bad idea and puts every device on your home network at risk Nov 9, 2017 at 1:08

2 Answers 2


To do this you need the IP address of your Pi on your local network. You can get that with ifconfig on the command line. Let's say, for example, that it was

Then you want to forward port 22 from your router to your Pi. (Port 22 is the standard port for ssh.) In the input form that you have, it looks like that will require a row that looks like this:

22, 22,, 22, 22, TCP`  

Then probably you need to click "Enable".

You'll also need to know the public IP address at your house to make the connection from work. You can get that if you Google for "ip address". They will display your public IP address at the top of the results page. Let's say, for example, that you got

Now you can connect by ssh to your public IP address to connect to your Pi. From Linux that would be

ssh [email protected]

Using the (notional) IP addresses in the text above. You need to modify that to your actual public IP address.

Before doing this, however, note the following:

  1. Anyone else can also ssh to your Pi using your public IP address. You'll need to take care with security. You will be scanned by bots that try to log into port 22 using common passwords and other exploits. Right now your router's firewall is blocking that out for you.

  2. If someone penetrates your home network because you enabled port forwarding and made a security mistake, they will likely be able to take control of other computers and devices on your home network.

Take care!

  • Thanks, but I have already tried exactly this. It simply won't connect, any thoughts?
    – Panga97
    Nov 8, 2017 at 22:26
  • Your ISP may block port 22 or some other firewall device on your network may block it. Also your public IP probably changes at unpredictable times, but it should be at least a bit stable.
    – Brick
    Nov 8, 2017 at 23:27
  • @Panga97 Are you trying from outside the local network. Nov 9, 2017 at 1:11
  • @Brick +1 for mentioning the security implications. Nov 9, 2017 at 1:11
  • Thanks I got it working now, I was trying to connect to the internal IP adress like an idiot.
    – Panga97
    Nov 11, 2017 at 23:03

The only port that matters is the internal ssh port and host. If you want to ssh into a machine on your LAN that has a LAN address of something like ---- You would put that address in the internal IP address along with port 22.

The external port doesn't matter, all that matters is that the port you choose is not blocked by your ISP. You would then connect to your LAN machine using the Internet addressable IP (WAN) of your router and the external port you chose.


You should be able to connect to your machine via:

ssh -p PORT [email protected] 

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.