[Dnsmasq-discuss] dynamic dhcp-host entries?
simon at thekelleys.org.uk
Sat Sep 2 11:26:41 BST 2006
Eldon Ziegler wrote:
> I have an application that generate virtual machines dynamically. Each
> virtual machine is assigned a MAC and IP address at the time it is
> generated. Is there a way to, in effect, enter and remove dhcp-host
> entries so that when the virtual machine boots and does a dhcp request
> it will receive the IP address that was assigned?
If you store the IP address - MAC address pairs in /etc/ethers and run
dnsmasq with the --read-ethers flag, then it will use that information
to assign IP addresses. See man (8) ethers for details of the format.
On allocating a new virtual machine, your application will have to add
the IP and MAC addresses to /etc/ethers, and then send dnsmasq SIGHUP,
which will cause it to re-read /etc/ethers. Similarly, removing a line
from /etc/ethers will remove the static address allocation.
Note the removing the static address will not remove an existing DHCP
lease, but next time a client attempts to renew the lease, it will cause
the client to get a NAK reply from the server if the address it holds is
outside the range for dynamic address allocation.
That should do what you want. Make sure you are using a fairly
up-to-date release of dnsmasq if removing static entries matters to you
- there were some changes to that code a few releases back.
More information about the Dnsmasq-discuss