0

I have set up port forwarding for my network to be able to ssh into my server from outside the network (let's say external port 10122 maps to internal port 22 for 192.168.1.101).

Let's say my computer has the IP 192.168.1.102, the server has 192.168.1.101

I can do ssh [email protected] and it will work. I can do ssh -p 10122 root@<public IP> and it will work ONLY if I'm not connected to the local network

Why is it that I can't invoke ssh -p 10122 root@<public IP> from within the network?

I googled around and only getting information on how to do port forwarding or use iptables to open ports (but this is all already working).

EDIT: I don't need to use the external IP to access an internal machine, I've hit this problem more than once and would like to know more and be able to explain why if someone were to ask me.

7
  • "Why is it that I can't invoke ssh -p 10122 root@<public IP> from within the network?" limitations of your networking hardware
    – Ramhound
    Commented Sep 13, 2017 at 21:45
  • @Ramhound: can you explain a bit more on why this would be a limitation? If the port forwarding policy is in place and the router can handle internal ssh as well as external ssh from outside the network, it seems to me that it should already be able to handle ssh using external IP from inside the network, especially if router is aware of its assigned IP, it can just handle an extra step in the network layer to route locally.
    – PGT
    Commented Sep 13, 2017 at 21:49
  • Why do you want to use the public IP address instead of the local intranet IP address anyways? As for the reason: en.m.wikipedia.org/wiki/Network_address_translation
    – Ramhound
    Commented Sep 13, 2017 at 22:09
  • 3
    Reference here: en.m.wikipedia.org/wiki/Hairpinning Commented Sep 14, 2017 at 4:10
  • 3
    Possible duplicate of Unable to outside access service from inside LAN Commented Sep 14, 2017 at 13:57

0

You must log in to answer this question.

Browse other questions tagged .