-
Notifications
You must be signed in to change notification settings - Fork 7.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DNS gets corrupted after a short time #8221
Comments
dnsIP != localIP != gatewayIP |
Could you elaborate on this? The dns returned from dhcp is the same as gw, but ip is .100 |
I think it has to do with the DHCP server in the WiFi Router. Would it be possible that the DHCP lease time expires and some other AP/Router responds to the ESP32-S2 STA with a new DNS information? |
No other dhcpv4 exists on this network, but it does have v6. Could that be it? The lease is 1hr though. I have three customers reporting the same issue, so it is not a problem spesific for my network. |
Not sure... you can try it by turning off the v6... just to make sure it is not the cause. I only have a dhcpv4 here. I'll let you know. |
I have two VLAN from my router, one for IoT and one for everything else. The IoT network has its own subnet and WiFi. If I switch to IoT WiFi the problem does not appear actually (just double checked). But if I put in on the "normal" WiFi, it happens within 10mins. The only difference as far as i can tell is the v6 provided by radvd on my pfsense router. There are also some difference in DTIM on WiFi, but I don't think that is the problem. I just changed the router config to turn off v6, and the DNS on the ESP instantly changed to 0.0.0.0. I reset the device and left it running for 15 minutes. Still no change in DNS, so it could look like we are on the right track. I have to leave for work, but can leave the device running through the day. I know that at least one of my customers have the same ISP as me, which means he also have native ipv6 on his network. He uses the ISPs standard router, which means we have different brand router and AP. If there is anything I can do to increase debug logging from the ESP to see what it receives, please let me know. |
I have tested it for almost 8 hrs. It keeps the ESP32 DNS IP always the same. If I change it in the WiFi router, it changes in the ESP32 after DHCP leasing period expiration (renewed in the re-leasing). |
One way to increase the debug logging is to set verbose logging in the IDF level. I think that using Arduino as IDF component may be the easiest way to go. |
Thanks, I'll try this when I get home. I haven't used IDF that much, but I think I'll find my way around. I'll report back what I find |
I have also seen this happening lately, where the DNS suddenly becomes garbage. Not sure how long this issue may already be present, but I'm only fairly recent aware of these things getting corrupt. |
This very interesting, @TD-er. There may be some problem with LwIP layer when a new DHCP lease request happens... |
Maybe it is something as simple as a new IP-address being generated from some uninitialized uint32_t, or trying to parse a DHCP reply which is expected to be longer. |
Arduino layer doesn't deal with DHCP client transaction (STA mode). It is only done in the IDF level through LwIP. |
I can't leave the DNS2 IP address unset or as 0.0.0.0 in my router. I must set both DNS addresses to valid IPs. I start to think that this issue is related to how the WiFi router or the AP works... maybe not related to the ESP32. |
I'm using a Fritzbox router here. Can you also try to toggle WiFi mode to off and STA mode again? |
@TD-er - I have tested it by toggling OFF <--> STA every minute and displaying the DNS addresses. No issue here. |
@TD-er @gskjold - I may have found a work around that may work for your projects. It is possible, with Arduino 2.0.9, to set a static DNS IP address that will never change along the sketch execution and will not be subject to the DHCP Server of the LAN. Example: void setup() {
WiFi.begin(SSID, PSW);
if (WiFi.waitForConnectResult() == WL_CONNECTED) { // default timeout is 60,000ms = 1 min
// set the static DNS IP addresses
IPAddress DNS1 = WiFi.gatewayIP(); // it is common to use the Gateway IP as DNS Server IP Address
IPAddress DNS2 = IPAddress(8, 8, 8, 8); // Google DNS server
WiFi.config(WiFi.localIP(), WiFi.gatewayIP(), WiFi.subnetMask(), DNS1, DNS2);
} else {
log_e("WiFi Connection Error!");
}
} |
When I came home from work this afternoon I messed up my test and restarted the device... But I have left it running since, and it have been rocking the correct IPv4 DNS for the last three hours. Just re-enabled IPv6 and RADVD in my router and the DNS on ESP got corrupted immediately after. It seems to me like there is something in the IPv6 router advertisement that ESP picks up and overwrites the IPv4 DNS. Regarding the workaround, forcing a fixed DNS on my customers is not my favorite pick I'm afraid, but thanks for the tip |
I forgot to mention I also have IPv6 here in my network (full dual stack IPv6 & IPv4) |
OK, so I have some new information. Because I have used Combined with my current radvd.conf, the problem can be reproduced, but I guess the tasmota builds are not your problem.
Having a low |
@Jason2866 is the mantaniner of Tasmota project. He may help with it. |
Also note that 32.1.70.66 == 2001:4642 |
Pin the platform version, as described in the readme here https://github.com/platformio/platform-espressif32 |
Btw. we do not have issues with DNS in project Tasmota. We have some DNS handling in Tasmota code... |
I was unclear. The DNS part is not working correctly. We have added a workaround in Tasmota code to solve the issue. |
Does that mean there will be a new version of tasmota/platform-espressif32 that solved this issue? Currently on 2023-05-00, but have also tested 2023-05-01 which has the same problem |
No, we will not dive in the very deep rabbit hole of lwip source code. We are happy we found the weird issues with Ethernet and WiFi using together we had (DHCP timeout, Ethernet got no IP) . It is caused from actual lwip code used in IDF 4.4.4. Solved by using a older lwip commit (not knowing the code part which is making the issue). The DNS issue is in all lwip versions. The lwip Ethernet / WiFi get no IP issue, is dependent of used LAN and WiFi hardware. |
Thank you for the input. I will find some way around it I guess |
I have updated my test code to better display this.
If I run |
@gskjold With what platform? The Tasmota version? |
Yes, platform = https://github.com/tasmota/platform-espressif32/releases/download/2023.05.01/platform-espressif32.zip |
@gskjold TASMOTA included support for ipv6 a few months ago. It also uses an older version of lwip as Jason noted. Ipv6 has not been merged into this repository. Does the DHCP issue happen with our v2.0.9? I'm currently using a modified version of a tasmota 2.0.7 branch. |
When switching to platform = [email protected] which is using 2.0.8, the issue is not there. As pointed out by @Jason2866 above, this issue is caused by lwip in esp-df 4.4.4 and not actually arduino code, so the arduino version is irrelevant, any build based on idf-4.4.4 will have the issue. So technically I guess this issue belongs to the idf repo now. |
2.0.7, 2.0.8, 2.0.9 are all based on IDF 4.4.4. |
Then I'll take a wild stab and say that the build flags that enable IPv6 are not set in vanilla arduino-esp32, but is set in tasmota. From what I can remember digging into the lwip ipv6 code, there are a few build flags to enable to get to the code i reference here: #8221 (comment) |
@gskjold Yes, there are more enable IPv6 options set in the Tasmota Arduino Lib Builder than in the orig. espressif Arduino Lib Builder. |
Possibly related #8672 |
Not sure as the DNS may also get corrupted/erased whenever the WiFi is turned off. |
Is the issue still present? |
Not sure. It requires testing. @gskjold - Could you please revalidate this issue using the latest ESP32 Arduino Core released version? |
Board
Custom board with ESP32-S2 mini
Device Description
Custom board (https://amsleser.no) for reading smart meters
Hardware Configuration
GPIO10 = Voltage divider
GPIO13 = LED
GPIO14 = LED
GPIO16 = Serial RX
The following GPIO have been grounded to improve GND routing:
11, 12, 21, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 45, 46
Version
v2.0.9
IDE Name
PlatformIO
Operating System
Linux (Ubuntu)
Flash frequency
40MHz
PSRAM enabled
yes
Upload speed
460800
Description
It connects to the WiFi and has the correct IP for a little while. In my case it changes from 192.168.28.1 to 32.1.70.66 within 10 minutes of starting the code, but from what I hear from users of the project where this was brought to my attention, it seems like the time varies (https://github.com/UtilitechAS/amsreader-firmware)
This could be related to network configuration, but I am out of ideas on how to debug this.
Sketch
Other Steps to Reproduce
Insert your SSID and PSK in the code, boot and wait at least 10min (maybe more)
I have checked existing issues, online documentation and the Troubleshooting Guide
The text was updated successfully, but these errors were encountered: