远程访问台式机到LTE调制解调器后面的树莓派,以及动态IP地址。

huangapple go评论56阅读模式
英文:

Remote access from Desktop to RPI behind an LTE Modem and dynamic IP address

问题

我正在尝试从我的桌面远程连接到我的RPI Zero2W。

以下是当前的环境:

  1. RPI和桌面位于不同的网络上,RPI连接到LTE调制解调器,桌面连接到路由器。
  2. LTE调制解调器在启动时会更改IP地址,并且不允许端口转发。
  3. LTE上唯一已知开放的端口是端口1883(MQTT)和端口8883(MQTTS)-->路由器本身通过MQTT协议提供通信。

由于这些复杂的连接要求,我一直无法远程连接到我的RPI。

互联网上提供了各种解决方案:

  1. 使用VPN:我尝试过使用WireGuard,但在路由器端口转发方面遇到了问题。为了使端口转发起作用,我需要知道连接到LTE调制解调器的RPI的IP,但由于IP是动态的,因此使用端口转发没有用,它甚至不在同一个网络中。
  2. 使用第三方应用程序:我尝试过使用Ngrok,但由于它需要端口转发,所以只能打开端口1883和8883,其中端口1883用于与服务器进行MQTT通信。唯一可用的是端口8883,但由于我想使用SSH,我需要使用端口22,而端口8883不适用。
  3. SSH隧道:同样,由于双方都需要端口转发,我也无法成功实现这一点。
英文:

I am trying to connect remotely to my RPI Zero2W from my desktop.

Here is the current environment

  1. The RPI and Desktop are on separate networks, the RPI is connected to a LTE Modem and the desktop to a router
  2. The LTE modem changes the IP address every time on startup and does not allow port forwarding
  3. The only known ports that are open on the LTE are port 1883 (MQTT) and port 8883 (MQTTS) --> the router itself provides communication with MQTT protocol

Due to these complicated connection requirements I have not been able to connect remotely to my RPI at all.

The internet suggests various solutions:

  1. Using a VPN: I have tried using wireguard but got stuck on the router port forwarding. In order for the port forwarding to work I would need to know the IP of the RPI connected to a LTE modem, but since the IP is dynamic there is no use using port forwarding, it is not even on the same network.
  2. Using third party apps: I have tried using Ngrok but since it requires port forwarding I am only able to open ports 1883 and 8883, from which 1883 is used for MQTT communication with the server.
    The only one available is port 8883, but since I want to use ssh I need to use port 22 which port 8883 isn't
  3. SSH tunneling: Again since both sides require port forwarding I have not been able to successfully pull this off either

答案1

得分: 1

以下是翻译好的部分:

根据我的理解,一些端口是开放的,这意味着你可以从你的桌面连接到这些端口,只要你知道RPi的IP地址。但是从RPi,我认为你可以连接到其他端口,如443。

我建议使用以下解决方案:

在你的RPi上,运行以下命令 ssh -p 443 -R0:localhost:22 tcp@a.pinggy.io。这将为你提供一个地址和端口,用于从你的桌面访问RPi。

现在有一个注意事项,在重新启动后,这个地址将会更改。你可以通过以下方式找到地址:

  1. pinggy.io 上创建一个免费帐户。

  2. 在你的RPi上使用以下命令(将 yourtoken 替换为你的pinggy令牌):

    while true; do 
        ssh -p 443 -R0:localhost:22  yourtoken+tcp@a.pinggy.io; 
        sleep 5; 
    done
    
  3. 然后从pinggy仪表板中,你可以随时检查你的当前地址和端口。

披露:我是Pinggy团队的一员。

英文:

As per my understanding some ports are open meaning you can connect to those ports from your Desktop provided you know the IP address of the RPi. But from RPi I assume you can connect to other ports such as 443.

I would suggest this solution:

On your Rpi, run this command ssh -p 443 -R0:localhost:22 tcp@a.pinggy.io. This would give you an address and port using which you can access your RPi from your desktop.

Now there is a catch, on a restart this address will change. You can do this to figure out the address:

  1. Create a free account on pinggy.io

  2. Use the command on your RPi (replace yourtoken with your pinggy token):

    while true; do 
        ssh -p 443 -R0:localhost:22  yourtoken+tcp@a.pinggy.io; 
    sleep 5; done
    
  3. Then from the pinggy dashboard you can always check your present address and port.

Disclosure: I am a part of Pinggy team

huangapple
  • 本文由 发表于 2023年5月23日 01:16:22
  • 转载请务必保留本文链接:https://go.coder-hub.com/76308541.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定