[Dnsmasq-discuss] generating hostname on the fly, base on mac address,
Sébastien G
sebastien at alternatives.ca
Fri Mar 5 14:02:21 GMT 2010
hi folks,
Dnsmasq is a great software, I use it everywhere I can! Now, I'm
facing an issue when automating the installation process of
Ubuntu/Debian. To make everything follow, I want to configure dnsmasq
to provide to a new host being installed a generated hostname.
(something like pc<XX-XX-XX-XX-XX-XX> (the mac adress of the host)
I know about the /etc/ethers where I can assign hostname and ip to a
specific mac address. The problem of using the /etc/ethers method is
that I need know the mac adress *before* doing the installation processs
and add it to the config file. This is not very pratical for us when
doing a lot of installations.
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...
Do people have had an issue like this before? is dhcp-script the way to
go to generate hostname on the fly base on the mac address?
Thanks for sharing,
Sébastien
More information about the Dnsmasq-discuss
mailing list