Nodemcu固件无法解析DNS或使用HTTP客户端,但能连接到工作的Wi-Fi接入点。

我可以使用来自readthedocs的默认init.lua连接到AP。-- https://nodemcu.readthedocs.io/en/master/en/upload/

但DNS不起作用,HTTP客户端也不起作用。

我编辑了credentials.lua,以匹配我的SSID和密码。它成功连接到我的WiFi

我使用此示例脚本进行确认:

do
local sta_config=wifi.sta.getconfig(true)
print(string.format("\tCurrent station config\n\tssid:\"%s\"\tpassword:\"%s\"\n\tbssid:\"%s\"\tbssid_set:%s", sta_config.ssid, sta_config.pwd, sta_config.bssid, (sta_config.bssid_set and "true" or "false")))
end

结果:

[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.2.0 | ChipID: 0x813d2b | FlashID: 0x1625c2
[NodeMCU] Running "getapinfo.lua"
[NodeMCU] >----------------------------->
当前站点配置
    ssid:"JohnnyCinco"  password:"88888888"
    bssid:"00:05:4e:4c:3e:0b"   bssid_set:false
[NodeMCU] >----------------------------->

我使用此示例脚本进行确认,我获得了IP。

ip, nm, gw = wifi.sta.getip()
print("IP Address is:")
print(ip)
print("NM is:")
print(nm)
print("GW Address is:")
print(gw)

结果:

IP Address is:
192.168.61.197
NM is:
255.255.255.0
GW Address is:
192.168.61.1

这是此路由器的正确IP。

但简单的DNS失败。我创建了一个带有来自nodemcu的示例的脚本。

net.dns.resolve("www.google.com", function(sk, ip)
    if (ip == nil) then print("DNS fail!") else print(ip) end
end)

这是结果。

[NodeMCU-Tool] Connected
[NodeMCU] Version: 2.2.0 | ChipID: 0x813d2b | FlashID: 0x1625c2
[NodeMCU] Running "getgoogdns.lua"
[NodeMCU] >----------------------------->
null
[NodeMCU] >----------------------------->

即使我从DHCP获得了DNS服务器,我也将其更改为8.8.8.8进行测试,但仍然失败。

我可以创建http服务器并从LAN上的其他WiFi客户端访问它,该部分有效。但DNS查找和http客户端请求都失败。

这个WiFi AP适用于所有其他客户端。没有防火墙。为确保我尝试了两个不同的路由器。我还尝试了第三个路由器,其具有蜂窝互联网,而不是我的有线互联网。全部失败。

这是nodemcu版本2.2.0。我已尝试过dev和master分支。两者都产生相同的结果。

我尝试过在nodemcu-build.com上构建,以及在自己的Linux机器上构建。两者都失败。

我已经尝试了来自不同供应商的4个不同ESP8266开发板。全部失败。

我错过了什么?我必须错过了一些基本的东西。这太基本了,以至于不能坏。或最新的固件是有问题的?

谢谢 J5

点赞