-
Notifications
You must be signed in to change notification settings - Fork 13.3k
ESP8266 WiFi Client does not honor DHCP host-name option setting when using DHCP #5695
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
Comments
Do I understand this correctly: you want the ESP to set its hostname as specified by the DHCP server via a received option? On the ESP, the dns hostname can be defined from:
Network-wide, the hostname is specified with:
If the above is correct, then I think we need to discuss priorities. One possibility:
BTW, you seem to be thinking of the ESP only as a network-attached device, Don't forget that it has a SoftAP interface, and it can serve its own network. Within that network, it's the ESP who is both the DNS and DHCP server. This case must also be taken into account. |
Yes, the priorities qualification, I believe is correct. Which I think you have qualified well above. Moreover, it mirrors typical behavior of other environments, i.e. OSes, etc. Yes, I am aware of the different modes of use possible. I actually plan to setup DHCP/DNS services on a ESP device as recovery resource in my home network... just awaiting for the package to arrive. Typically a network services device is a static configuration as a best practice, of course. And, yes, this would be a new case, but IMHO it should have been done as one of the default options in the original design. Consistent behavior in respect to DHCP options I believe would be a significant and valued addition to the SDK/API. |
We are using lwIP and after checking latest stable version, which we use, lwIP itself does not honor dhcp received hostname option, but provides a way to parse received options it doesn't use. However we would have this real DNS hostname only when the esp is a dhcp client. A static hostname will fail with the security argument you mention in #5574 (comment) . edited: this is reverse dns lookup, see below We must not forget about mDNS, which is a way to unilaterally claim a hostname (automatically updated when name collisions occur). mDNS names are now well known from OSes (bonjour or ahavi daemons on the three main OSes). How should we handle that dual identity ? Can we always match one to the other ? Decisions have to be taken before going further. I'm not fully aware on how it is done on main OSes. (inviting @LaborEtArs and @hreintke about the DNS/mDNS duality) |
If some kind of network admin sets a hostname for a device, then this should be respected a good as possible. In my knowledge, there are at least three options to set the hostname:
|
I believe we see the scenario the same way. In a typical top down, secured environment, DHCP reservations are explicitly done, are static, thus DNS is not dynamic, and DHCP reservations mirror static DNS assignment. The expectation is that DHCP reservations are synchronized with static DNS of course. This is the scenario being asked for, that if DHCP has set the host-name option, it is honored, unless, device device static assignment is done, i.e. SoftAP, or direct assignment via API, or Dynamic DNS owns the environment. If Dynamic DNS is used, then explicit or static DHCP reservation would not, should not, be used, or even honored, because Dynamic DNS must inform DHCP of the applicable host-name, as applicable, as you noted. Honoring DHCP reservation, i.e. host-name option use, would not, and should not override dynamic DNS priority, if Dynamic DNS is used. Of course, the use of Dynamic DNS in secured environments is not best practice, but I digress. |
Would it be then
|
Yes, seems the right strategy to me. This always for static environments (where DHCP and DNS are predefined, such as in secured environments, and also supports use of dynamic DNS environments if that is desired, needed. |
Any progress on this? Expectation of when it will be added? Just curious. Also, just did some testing with ESP 32 devices, and the same issue results, DHCP host name option is not honored it appears. Was using the Arduino/espressif library ESP 32, and Arduino ESP8266WiFi/WiFiMulti for ESP 8266 of course. Never mind the fact that the WiFi and WiFiMulti libraries exhibit a lot of variance between API definitions and features between the two device classes/types. It was really frustrating to have to do a lot of #defines to isolate ESP 32 and ESP 8266 coding because the same named libraries are not identical at the API definition/call level. Does not make any sense to me... but I digress. Maybe how DHCP host name option can be consistently implemented for ESP 32 and ESP 8266? That would be a wonderful thing, IMHO. |
as suggested by @d-a-v I would love to be able to define a callback / hook to use unused DHCP options (using LWIP_HOOK_DHCP_PARSE_OPTION it seems) instead. This would allow those that want to set the hostname as well and also support other scenarios in lieu of a permanent solution. One of the things I need for example is to pick up the NTP server and timezone from the DHCP options, something that is also not possible at this moment. Let me know if this would be a good idea, I am also more than happy to submit a patch to implement if someone could point me in the right direction w.r.t. to the procedure for that. |
Everything is feasible. Just do it ™. yakafokon. Time is needed.
This is already done and working (for NTP server, timezone I wasn't aware it is in DHCP header) Our API is not sufficient and does not allow full genericity, either:
|
FWIW #6680 will add LWIP_HOOK_DHCP_PARSE_OPTION. |
Cool! |
Basic Infos
Platform
Settings in IDE
Problem Description
Detailed problem description goes here.
DHCP ip address acquired by device as expected with WiFi configuration. However DHCP host-name option is not honored, the automatic host name is reported by the WiFi.hostname() call, not the name assigned in the DHCP reservation on DHCP server for said MAC address of device.
DHCP Reservation Example... Note the host-name option value of "Node01"
Debug Messages
The text was updated successfully, but these errors were encountered: