Static DHCP lease for a machine with no hostname

I have a device that does not report a hostname when getting an address from DHCP - so the openWRT box only knows the IP address and MAC

If I tell openWRT to set that lease as static via the webUI, then it causes the DHCP server not to start up. On investigation, it looks like this when requested that the device get a atstic IP, the hostname is listed as "-" in the leases file, which causes a parse error:

uci set dhcp.@host[-1].name='-'
uci set dhcp.@host[-1].ip=''
uci set dhcp.@host[-1].mac='30:FF:F6:83:60:A2'

Is this a known problem?

I'm not sure about what the spec says on this (if there is any). But why not assign it a hostname yourself in /etc/config/dhcp? It won't do any harm?


The requested name does not need to match the assigned one.
Or you can simply omit the host name as this parameter is optional.


Yes just change hostname to whatever you want, it should be unique in your network. Or remove the hostname line entirely-- if host does not supply a hostname it will go in the table as '*' and it's not possible to DNS lookup.

For further background it is not necessary to enter both hostname and MAC you only need one of them.

If MAC matches, the IP is assigned and the DNS name will be either the hostname supplied by the host, or it can be overridden with the hostname parameter.

If MAC is not specified but hostname is specified and it matches, the IP is assigned to the first host that requests with that name. This is the preferred way to set up the network. If a network card is changed or the connection is made by wifi instead of wired, the same IP is assigned.

It also works to specify hostname and MAC but not IP. A dynamic IP hashed from the MAC will be issued the same as if no reservation existed. But DNS for that device will be linked to the hostname that you entered. This is useful when you have devices that don't send a hostname, or multiple devices that send the same hostname.


Ah cool OK - via the GUI I can't not include the hostname, and "-" is invaliud - but by doing it manually at the command line, and/or editing the file afterwards I can.

Might it be possible for the default hostname used in such a situation to be something valid (or not used at all) when editing via the UI?

Empty host name works for me on OpenWrt 19.07.5 using LuCI.

Yep, you can specify anything matching the valid syntax: