首页 > 解决方案 > 如何从外部网络访问在双 NAT 网络中运行的 webserver

问题描述

这不是编程问题,更可能是网络问题。对不起,如果我不应该在这里发布这个问题。

我正在尝试使用我的公共 IP 从外部网络访问控制我的微控制器 GPIO 的 Web 服务,但我无法访问。经过少量研究,我知道我的 ISP 正在使用双 NAT,并且无法从外部网络访问。但是Blynk我手机上的应用程序能够从外部网络触发我的微控制器(通过在Blynk云中注册我的微控制器)。

我的问题是如何Blynk能够接触到在同一个双 NAT 网络后面运行的设备。

提前致谢。

标签: iotnat

解决方案


Your difficulty is in having a server initiate a connection to your device when the device is behind double NAT. The Blynk library, which you install on your device, initiates the connection outwards to a Blynk server, which is not behind any NAT. Much the same as your device can initiate an HTTP request for a website and receive a response

Once that connection between device and server is established, traffic is exchanged over that.

To do something similar you essentially want to reverse your thinking of the client/server roles. When you say you’re trying to “access the webserver [on your microcontroller]”; you’re treating your microcontroller as the server. Your microcontroller should be the initiator of the connection (usually the client role).

You can have the device initiate a socket connection to a socket server (which is what blynk is doing) or have it initiate a VPN connection (you can then use the VPN tunnel to treat the device and server as if there is no NAT)


推荐阅读