DHCP gateway problem after first refresh (leasetime) (STA mode)
atnel opened this issue · comments
Hi,
I'm using NONEOS AT SDK v.3.0.4. There is small but BUG, when DHCP refresh data from router in STA mode after lease time.
FISRT time after we connect to router - DHCP get right data - especially Gateway. In my net there it's: 192.168.2.2
SECOND - allways after DHCP refresh data from router, my Gateway become value: 192.168.2.1 (wrong).
IP and MASK are always ok.
Please try set 2-3 minutes lease time in your router and check this. I have tested this on many routers and many esp8266 modules.
Mirek
It looks like I have the same problem.
After connecting to WiFi: ip: 192.168.100.209, mask: 255.255.255.0, gw: 192.168.100.2
Lease renewal:
ip: 192.168.100.209, mask: 255.255.255.0, gw: 192.168.100.1
The problem is particularly troublesome for those users who have a short lease time set and a gateway address that does not end with 1.
The problem is particularly troublesome for those users who have a short lease
If I did not have a short lease time set, I would not notice (probably like many people) that this problem exists - or I would look for a problem longer - why my device stops working in certain situations, e.g. after 24 hours ;)
There is one more strange case that changes the mask too.
Once connected, an address is assigned
ip: 10.0.4.13, mask: 255.255.255.0, gw: 10.0.4.1
and when renewing the lease, the mask and gate change to
ip: 10.0.4.13, mask: 255.0.0.0, gw: 10.0.0.1
So for now, there is only one workaround is for that: using static IP only
We have verified that this problem occurs from version >= 3.0.1
I have the same problem.
After connecting to my WiFi network:
ip:10.4.55.93,mask:255.255.255.0,gw:10.4.55.254
when trying to renew address, the mask and the gate take wrong values:
ip:10.4.55.93,mask:255.0.0.0,gw:10.0.0.1
I have the same problem :(
After connecting to my WiFi network:
ip:10.0.144.26,mask:255.255.255.0,gw:10.0.144.2
when trying to renew address, the mask and the gate take wrong values:
ip:10.0.144.26,mask:255.0.0.0,gw:10.0.0.1
Could be this
lwip-tcpip/lwip@a8e8ce4
After a little investigation, I found that the DHCP client was incorrectly parsing the ACK frame when renewing the lease. In version 3.0.0, this problem did not occur because when renewing the lease, the dhcp_handle_ack (netif) function; was not invoked, which was changed in v3.0.1
959a873#diff-c6c5e739ad3c7a974403ee2df2e4710a220acd785d116f875091cc3f8751091cc3
https://github.com/espressif/ESP8266_NONOS_SDK/blob/master/third_party/lwip/core/dhcp.c#L1746
Now I analyze the parser why it can't handle ACK on renewal ....
Could you try AT+RESTORE?
The commit pointed to by @kriegste does not fix this problem. This sets the gate to 0.0.0.0 when renewing. I have submitted a PR with a working patch.
Unfortunately (fortunately...) I cannot reproduce the error. But the netmask, too, seems to be set to a default. That should be fixed as well.
He will also prepare a fix for the mask.
I added an amendment regarding the mask.
Thanks. Let's see what the testers say...
Hello,
Could you provide the router manufacturer and model number, which we can reproduce the issue?
If there are multiple routers, please provide them all, and we can check if we have one.
Yes, this PR resolve the problem. Confirmed by several of our users.
I confirm, problem solved :) Thanks
I also confirm. The problem has been solved.
Yes, this hotfix fixed the problem. Thanks @przemyslawzygmunt
hotfix OK
The patch suggests the issue only shows when the DHCP server does not supply a netmask (which is bad imho). So that's probably why I don't see it.
Mask or IP address
Even more sounds like a completely broken DHCP server :-(