-2

Well I'm running ssh server on my laptop which I'm portforwarding to my router and I assume that I can now connect through my routers ipv4 and port in order to tunnel back to my laptop but it doesn't work like that does it.

Can someone explain to me what I need to do in order to make this work. Simply please I don't want to get confused and I know this is a noob question but I went straight to other things instead of learning some basics and now I'm feeling the consequences lol.

RennJutsu
  • 1
  • 1
  • Please provide enough code so others can better understand or reproduce the problem. – Amit May 31 '22 at 02:05

1 Answers1

0

Depends from where do you want to access your laptop. If it's just from your local network or LAN, you don't need to setup anything on the router. If, however, you want to access it from the internet, you need to setup port forwarding on the router, but probably also set it up with your ISP.

SSH server setup

SSH server normally runs on port 22 (SSH port). At first your laptop's firewall blocks all incoming traffic! So in order allow people to access your laptop through SSH, you need to tell your firewall to allow incoming traffic on port 22. Also, if you haven't already, set a static IP on your laptop so that you can configure the router for port forwarding and access your laptop easily. And make sure to exclude the static address from the DHCP range (so that your router doesn't your static IP to another device).

LAN connection

In case of SSH connection only on your local network, all you need is the local IP of your laptop. That's it.

WAN connection (internet)

So first, of course, you need to enable port forwarding on your router and specify the port 22 and your laptop's local IP address. But you need to know how are you connected to the internet. Because, ISP's can have an intermediate layer (or layers) network. And this network eventhough is way bigger than you home network is still a private network, and uses private IP addresses. So in order to access your laptop through the internet, you have to talk to your ISP. And the final public IP is the one you would need to access the SSH server.

no name
  • 13
  • 5
  • What if I have the router public ip and know my ipv4 do I just port forward my ipv4 and port 22 to my public ipv4 and port 22. Seems not to work like that tbh – RennJutsu May 31 '22 at 14:16
  • @RennJutsu what router do you have? – no name May 31 '22 at 14:41
  • Sagecom 5260 spectrum wireless – RennJutsu Jun 02 '22 at 09:28
  • I believe this would do the thing [tutorial](https://youtu.be/TjiZI6mRZ7o). I personally haven't used that router, but the steps shouldn't differ much between different routers. So in external host specify all (asterisk *), in internal host the IP address of the laptop (the SSH server), and for port put 22 (both external and internal). And one more thing, you need to setup a static IP for your laptop, not DHCP (because you need to specify a static IP address in the port forwarding rule, one that will not change). – no name Jun 03 '22 at 07:15
  • In order to setup the static ip I just go to network configurations in my laptop correct ? – RennJutsu Jun 03 '22 at 12:45
  • Normally our ipv4 that is automatically given to us is static correct – RennJutsu Jun 04 '22 at 01:41
  • Yes, you need to set it up on your laptop (in network configuration) as well as on your router. You can search google how to set a static IP on your laptop, it's pretty straightforward (there are only 2 options for IP static IP - the one you wirte, and DHCP, which requests an IP address from the router). No to the second statement - normally your laptop is set to DHCP, because it's the easier, no configuration is required to browse the web. If it were normally static, you would need to manually give every device a static IP – no name Jun 04 '22 at 07:16