I have an own linux server (ngnix, gunicorn, python flask) connected it via dyndns to my frtizbox and to my domain and dyndns provider (selfhost.de). Now I would like to connect to this linux server using ssh like this:
ssh [email protected]
This means not with the ip addr cause this is changing in case of power breakdown or frit box restart.
I saw that there are services like ddclient. I set this service up but I do not know how to connect now using the above command: I still get this error:
ssh: connect to host domain_name.de port 22: No route to host
OS:
- Ubuntu server: 20.04 LTS
- Ubuntu Laptop I want to access the server with has: 18.04 LTS
Details: If I have both machines in the local network I already can access via:
ssh server_name@192.....
Next I tested with both machines having the same local network to connect with publich ip:
ssh [email protected]...... --> Error no route to host
I then allowed port 22 at my fritzbox and it worked!
Is this issue related to that both machines have the same public ip?
Next I tested to have my laptop in other network (hotspot with mobile phone)
ssh [email protected]...... --> Error no route to host
Finally I want to achieve above with domain name....
I then allowed port 22 at my fritzbox and it worked!
I also stopped now my ddclient: sudo service ddclient stop
and I still can access using
ssh [email protected]
Do I need ddclient at all?
No, this is because your public IP points to your Fritzbox and not the machines. So you need to tell the Fritzbox what to do with requests. That is why you use "Port Forwarding". Then, the Fritzbox forwards the traffic from that port to the local machine. You can also tell the Fritzbox to forward all traffic to one machine, but don't do this if you're not 100% sure what you're doing.
It works because your IP did not change yet. Once it changes,
domainname.de
will still point to the old IP address which then won't work. You need to tell the service provider your new IP address, and that is whatddclient
is doing automatically for you.Off-question notes:
Be aware that forwarding ports in your router comes with great risks. Your machine will get attacked (that is normal) and you should know how to deal with it:
fail2ban
You don't necessarily need all of this at once ...