[Dnsmasq-discuss] Automatic DHCP client naming

Sébastien Grenier sebastien at alternatives.ca
Tue Apr 20 18:21:33 BST 2010


El 16/04/10 10:43, Ferenc Wagner escribió:
> Hi,
>
> 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.

Hi Feri,
I did exactly that on a few dnsmasq setup, using the dhcp-script 
parameter, with the value, /usr/local/sbin/dnsmasq-genhostname.sh

here is the script
https://trac.redcta.org.ar/redcta/browser/trunk/puppet/modules/puppet-dnsmasq/files/dnsmasq-genhostname.sh
en svn:
https://svn.redcta.org.ar/proyectos/redcta/trunk/puppet/modules/puppet-dnsmasq/files/dnsmasq-genhostname.sh

it generate this
------
00:22:68:61:84:36,PC002268618436
08:00:27:94:e1:ec,PC08002794e1ec
00:03:0d:ac:89:30,PC00030dac8930
------
in the file /etc/dnsmasq.hostsfile

then I also, added the following line to the dnsmasq configuration file.
dhcp-hostsfile=/etc/dnsmasq.hostsfile

I've been using it for few weeks now and everything is working as expected.

On a side note, if you're doing masive deployment of dnsmasq, I've found 
very useful to build a puppet recipe to do the deployment.
https://trac.redcta.org.ar/redcta/browser/trunk/puppet/modules/puppet-dnsmasq/README

Cheers,

Sébastien



More information about the Dnsmasq-discuss mailing list