[Dnsmasq-discuss] generating hostname on the fly, base on mac address,

Sébastien G sebastien at alternatives.ca
Fri Mar 5 15:58:07 GMT 2010


>> So far, I've found that the dhcp-script could be helpful here. This is a
>> little script I've encounter, that has the basic idea of what I want to do.
>> ----------------
>> /usr/bin/add_new_host.sh*:
>> #!/bin/bash
>> if [ "$1" -eq "del" ]; then
>>   exit
>> fi
>> isnew_mac=$(cat /etc/dnsmasq.conf|grep -v "^#"|grep "dhcp-host"|grep
>> "$2")
>>
>> if [ -z "$isnew_mac" ]; then
>>   echo dhcp-host=$2,$3 >> /etc/dnsmasq.conf
>>   /etc/init.d/dnsmasq restart
>> fi
>>
>> ref:
>> http://linuca.org/pipermail/linuxcantabria/2006-June/007314.html
>> ----------------
>>
>> Doing a restart of the service in this script doesn't sound "right" to
>> me. but well...
>>
>>
> 
> You could put the name/MAC mappings in a separate file, and load it
> using dhcp-hostsfile. You can re-load the contents of that without
> having to restart dnsmasq by sending SIGHUP to the process.
> 
> Cheers,
> 
> Simon.

Thanks, I'll try that way as well.

Sébastien



More information about the Dnsmasq-discuss mailing list