Underscore character not allowed anymore in host names?

Hi !

When I want to put an underscore in a hostname in static lease section (for example "My_laptop"), Luci tells "Expecting: valid hostname"... "Mylaptop" is accepted.
It's pretty curious because when I was in version 18, it was ok and I still have some hostnames set with underscores from old settings.
Only since v19 and also in v21, it seems underscore works but cannot be set from Luci.

I was wondering why: is it on purpose for some reason or maybe a (minor) bug ?
I would like to add that opnsense (for example) is ok with underscore in hostnames ( I use opnsense router + a couple of openwrt dumb wifi AP).

I assume a workaround would be to set/modify hostname in settings files directly, but I was wondering what's the story behing this warning message.



Looks like the DHCP module's hostname validation is more restrictive that the main datatype validation.

DHCP (does not allow underscore, except as the first char???):

Main datatype: (seems to allow underscore)

@jow is probably the only one who remembers if there is any specific reason for that. Probably the reason that @vgaetera mentioned. As we do not know the OS of the DHCP client, it might be best to be restrictive and limit the hostname to the smallest common denominator. (But why then allow _ as the first char?)


Thanks for your feedback, I understand the point.
It should not be critical in my situation (even if I keep my old settings with still some underscore inside): I don't use the DHCP from Openwrt (they are dumb AP devices), but I use static lease to define a friendly hostname matching the MAC address on my network.
This way I can see the hostnames in the assiociated station on my WLAN.

Thanks again for clarification and I also learnt I can use "-" as separator instead of "_".