failover problems ?

Glenn Satchell Glenn.Satchell at uniq.com.au
Tue Dec 18 14:01:51 UTC 2007


>From: "Martin Damberg" <admin2 at vejen-net.dk>
>To: <dhcp-users at isc.org>
>Subject: failover problems ?
>Date: Sat, 15 Dec 2007 20:24:32 +0100
>
>Hello,
>
>Hope any one can me here :-)
>
>We have run into a difficult problem with the failover function in ISC.
>We use to run failover in the dhcp config, but because of problems with sync., 
server and etc. we removed all the failover 
>from the config. The problem is now that we have about xxxx-number of 
IPaddresses in the leases files
>that are all locked to "binding state backup". 
>
>I know the right way Was to do the PARTNER-DOWN method, but is it still 
possible for us to use that function
>without enabling failover, to get the addresses back ?!? I have thought about 
writing at script that can search/replace the leases 
>file but im not happy with it, especially if it goes wrong :-(
>
>The server i newst Debian, running ISC DHCP 3.0.4-13 stable
>
>Hope some one out there can help me, we'r almost out of addresses .. hehe. 
Thanks ....
>
>Martin

Write your script to edit the file, but don't overwrite the leases
file. Then use

  dhcpd -lf /path/to/editted/dhcpd.lease -t

to test the syntax of the generated file. When you're happy then
shutdown dhcpd, run the script and replace the dhcpd.leases file and
start the server.

A long time a go I wrote a perl script to clean up abandoned leases. It
could be easily modified to get rid of "binding state backup" leases.
No criticism of the code please, as you can see it's nearly 10 years
old, and I would probably do it differently now :)

#! /usr/local/bin/perl
#
# clean.pl
#
# Take a file, formatted as a series of records and clean up
# the abandoned leases if they've expired.
#
# Author: Glenn Satchell, glenn at uniq.com.au, 17 April 1998
#
# lease 203.2.13.146 {
#         starts 1 1998/03/02 22:01:24;
#         ends 2 1998/03/03 08:01:24;
#         hardware ethernet 00:c0:4f:db:4c:52;
#         uid 01:00:c0:4f:db:4c:52;
#         client-hostname "UserID1";
# }
#

$LFILE = "/usr/local/etc/dhcpd.leases";

open (LEASE, $LFILE) || die "Couldn't open $LFILE: $!\n";

@rec = ();
$abandoned = "";
while (<LEASE>) {
  if (/^}/) {   # last line
    if ( $abandoned eq "" ) {
        # write out the lease entry
        print @rec, $_;
    }
    @rec = ();
    $abandoned = "";
  } else {
    # if (/abandoned/) { $abandoned = 1; }
    if (/binding state backup/) { $abandoned = 1; }
    else { push @rec, $_; }
  }
}

regards,
-glenn


More information about the dhcp-users mailing list