0

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 username@domainname.de 

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 server_name@87.38......  --> 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 server_name@87.38......  --> 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 username@domainname.de 

Do I need ddclient at all?

  • Wow thanks I now found my problem port at frtiz box. But I still have the question if I do need ddclient at all? – sqp_125 Jul 24 at 5:58
2

Is this issue related to that both machines have the same public ip?

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.

I still can access using

 ssh username@domainname.de 

Do I need ddclient at all?

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 what ddclient 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:

  • keep software up to date (always!) and track relevant security bulletins
  • strong passwords or better: allow only key-based authentication
  • deny root login
  • use a port other than the standard port
  • use fail2ban
  • use a software firewall on the machine
  • use port-knocking

You don't necessarily need all of this at once ...

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.