[Dnsmasq-discuss] Automatic DHCP client naming

richardvoigt at gmail.com richardvoigt at gmail.com
Sat Apr 17 17:51:01 BST 2010


On Sat, Apr 17, 2010 at 5:20 AM, Ferenc Wagner <wferi at niif.hu> wrote:
> Simon Kelley <simon at thekelleys.org.uk> writes:
>
>> Ferenc Wagner wrote:
>>
>>> Simon Kelley <simon at thekelleys.org.uk> writes:
>>>
>>>> Ferenc Wagner wrote:
>>>>
>>>>> Is there any way in dnsmasq to push a hostname to a DHCP client
>>>>> even if it didn't report (or ask for) one?  I'd like to
>>>>> automatically name my clients based on their MAC addresses, like
>>>>> 00:11:22:33:44:55 should get the hostname
>>>>> 00-11-22-33-44-55.domain.tld.  Currently, I can get this effect
>>>>> only if the client sends its hostname in the DHCP request; then
>>>>> dnsmasq adds the correct domain, registers the name in its DNS
>>>>> database and sends back the fully qualified address.  Good.  But
>>>>> I'd like to avoid generating the ?hostname on the clients before
>>>>> starting DHCP.
>>>>
>>>> It would be possible to add that functionality, probably with
>>>> something like dhcp-ignore-names, say "dhcp-mac-as-name", but only
>>>> for a fixed name format (should there be a prefix?)
>>>
>>> Hmm, I'd rather extend the wildcarding already present in dhcp-mac with
>>> something like
>>>
>>> dhcp-mac=*:*:*:*:*:*,PREFIX*-*-*-*-*-*SUFFIX
>>>
>>> or
>>>
>>> dhcp-mac=*,PREFIX*SUFFIX
>>>
>>> with the replacement of colons implied.  On the other hand, I've found
>>> http://thread.gmane.org/gmane.network.dns.dnsmasq.general/3774/focus=3778
>>> just now...  Well, managing a registry from dhcp-script is almost
>>> acceptable, apart from the first run.  Here is another idea: why not let
>>> dhcp-script write back the hostname to dnsmasq?  That way no separate
>>> registry nor daemon restarts would be needed.
>>
>> Restart aren't needed: it's possible to re-read dhcp-host  lines on
>> SIGHUP is they are kept in a separate file.
>
> I fail to see how this could work reliably: the query may have been
> answered by the time the asynchronous dhcp-script gets around to signal
> dnsmasq to read the updated host data.

This is the reason for short lease times for clients that haven't been
given a name: to make them come back after a few minutes to renew at
which time they'll get their name and a normal duration lease.



More information about the Dnsmasq-discuss mailing list