У меня есть собственный сервер linux (ngnix, gunicorn, python flask), который подключил его через dyndns к моему frtizbox и к моему провайдеру домена и dyndns (selfhost.de). Теперь я хотел бы подключиться к этому серверу Linux с помощью ssh следующим образом:
ssh username@domainname.de
Это означает, что не с ip addr, потому что это меняется в случае сбоя питания или перезапуска frit box.
Я видел, что есть такие сервисы, как DDClient . Если у меня есть обе машины в локальной сети, я уже могу получить доступ через:
ssh server_name@192.....
Затем я протестировал на обеих машинах, имеющих одну и ту же локальную сеть, для соединения с pubich ip:
ssh server_name@87.38...... --> Error no route to host
Затем я разрешил порт 22 на моем fritzbox, и это сработало!
Связана ли эта проблема с тем, что обе машины имеют один и тот же общедоступный IP-адрес?
Затем я проверил наличие моего ноутбука в другой сети (точка доступа с мобильным телефоном).
ssh server_name@87.38...... --> Error no route to host
Наконец, я хочу достичь выше с помощью доменного имени. ..
Затем я разрешил порт 22 на моем fritzbox, и он заработал!
Теперь я также остановил свой ddclient: sudo service ddclient stop
, и я все еще могу получить доступ с помощью
ssh username@domainname.de
Нужен ли вообще ddclient?
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.
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 ...