So as I came to the office today I thought, wouldn't it be great if there was a tool that re-wrote the dhcpd config file based on a perl script?
Obviously I thought of doing this myself (as the programmer I am). But to make life a bit easier for myself I made a lookup at Google for dynamically updating ISC DHCP.
And woho! There's a pre-built API called OMAPI and someone built a tool on top of this called OMCMD.
After a couple of hours trying to get the stupid key to work (TSIG hmac-md5) I finally got it working.
For those of you who're used to update the DNS dynamically the syntax is about the same:omcmd [-K keyfile | -k keyname key] [-s server] [command]
Adding to DHCPomcmd -K keyfile -s 10.1.32.10 create host name=test ip-address=1.2.3.4 hardware-address=ff:ff:ff:ff:ff:ff hardware-type=1;
What OMAPI does is to write the new config to
/var/lib/dhcpd/dhcpd.leases, it looks a bit funky to me
hostname {
dynamic;
ip-address 1.2.3.4
hardware-address ff:ff:ff:ff:ff:ff;
};
But it works.
The script that I'm using looks like this:HOSTNAME=hostname.domain.com
IP=1.2.3.4
MAC=FF:FF:FF:FF:FF:FF
omcmd -k keyname md5hash create host ip-address=$IP name=$HOSTNAME hardware-type=1 hardware-address=$MAC
An issue that comes with using omcmd (I don't know if this is part of the IMAPI API) is that you cannot add DHCP entries pointing at hostnames rather than an IP-address.
The Swede in the middle of Silicon Valley
Monday, September 17, 2007
Dynamic updates of DHCP
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment