Editing dhcpd.conf without corrupting leases

Darren perl-list at network1.net
Mon Apr 13 18:37:09 UTC 2009

If using the process outlined below, I would check to make sure that / 
path/to/leases/file with a ~ (ie: the backup file) exists before I  
removed the original.  If not, your going to have trouble with leases  
that are assigned but unknown.  Duplicate IPs would be the result of  
that.  This could be a very bad problem depending on your lease length.

Like so:

until dhcpd -T -t ; do
	sleep 1
/etc/init.d/dhcpd stop
if ! dhcpd -T -t ; then
	if -e /path/to/leases file~; then
		rm /path/to/leases file
/etc/init.d/dhcpd start

On Apr 13, 2009, at 1:28 PM, Chris Buxton wrote:

> On Apr 13, 2009, at 10:12 AM, Mr. Jan Walter wrote:
>> It's also not clear from one paragraph what you're really doing, so  
>> don't get huffy when others' assumptions don't correspond to your  
>> reality. Really - sorry for trying to help.
> Sorry to break into your conversation here, but yes, it was clear.
>> There isn't any locking done on the leases or conf file by dhcpd  
>> itself. What's most likely happening (without me reading through  
>> all that source) is that if your web app's write of the config file  
>> is not complete, while your cron is sending the SIGHUP to dhcpd,  
>> some internal check fails and the leases file is considered corrupt.
> You've misread the original post yet again. The web app doesn't  
> touch the .conf file, the cron job does. And then, when it's  
> finished, it might restart dhcpd. This part is working fine.
> The problem is the lease database. The OP thinks that perhaps dhcpd  
> gets interrupted while writing out the lease database, thereby  
> corrupting it. But since dhcpd doesn't lock the file in any way,  
> there's no way to test for this.
> Adding a test step (dhcpd -T -t) will probably help, but it still  
> leaves a small window between that test and the subsequent SIGTERM.
> Ideally, the OMAPI protocol would be extended to have a 'reload'  
> command. Lacking that, I don't see a perfect solution to the  
> problem. The best I can think of is:
> _________________________
> #!/bin/bash
> until dhcpd -T -t ; do
>  sleep 1
> done
> /etc/init.d/dhcpd stop
> if ! dhcpd -T -t ; then
>  rm /path/to/leases file
> fi
> /etc/init.d/dhcpd start
> _________________________
> Chris Buxton
> Professional Services
> Men & Mice
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/dhcp-users

More information about the dhcp-users mailing list