DHCPD Scripts

Tim Peiffer peiffer at umn.edu
Thu Sep 25 00:50:50 UTC 2008


Tim Gustafson wrote:
> Hello,
>
> I am setting up a new ISC-DHCP server on a fresh FreeBSD 7.x box from the
> ports tree.  The server is running fine, but I have a requirement that I
> can't seem to find a good way to accomplish.
>
> Whenever an IP address is leased, renewed or released, I need DHCPD to fire
> off a shell script that will do a few accounting things for me (update some
> mySQL data, adjust the box's firewall rules, etc).
>
> Is there any way to configure DHCPD to run scripts like that?
>
> Thanks!
>
> Tim Gustafson
> SOE Webmaster
> UC Santa Cruz
> tjg at soe.ucsc.edu
> 831-459-5354
>
>
>   
I am a proponent of keeping tasks simple.. the dhcpd does its job of 
address assigment very well.  Being a gatekeeper, and a book keeper.. 
well, that is another story and better handled by something that can 
watch event streams.

Please check out the Simple Event Correlator (sec.pl) by Risto Vaarandi.
It is on the forge and it is a wonderfully flexible package.  While you 
are at it, check out John Roulliard's hints on service monitoring with 
the same package...

http://sourceforge.net/projects/simple-evcorr/

Tim Peiffer
Network Support Engineer
Office of Information Technology/NTS
University of Minnesota/Northern Lights GigaPOP

  sec.pl -conf=sec.cfg -input=/var/log/dhcpd.log

#Sep 24 00:00:02 server dhcpd: DHCPACK on 192.168.167.104 to 
00:18:73:fd:40:d2
via vlan520
sec.cfg
type=single
desc=dhcp server ack - commit
ptype=regexp
pattern=dhcpd: DHCPACK on (\w+) to (\w+)
action=spawn /usr/local/bin/leasetrack -ip $1 -mac $2

# a harder one to track might be leases
# sec.pl -conf=sec.cfg -input=/var/lib/dhcps.leases
#lease 134.84.254.153 {
#  starts 4 2008/09/25 00:34:49;
#  ends 4 2008/09/25 00:49:49;
#  binding state active;
#  next binding state free;
#  hardware ethernet 00:1d:e0:09:a7:19;
#  uid "\001\000\035\340\011\247\031";
#  set os-ident = "Microsoft Windows XP";
#  client-hostname "AKLthinkpad";
#}

sec.cfg
type=single
desc=dhcp server ack - commit
ptype=regexp
pattern=lease (\w+) {
action=eval %leaseip=( return "$1"; )

type=single
desc=dhcp lease start
ptype=regexp
pattern=starts \d (\w+ \w+);
action=eval %leasestart=( return "$1"; )

type=single
desc=dhcp lease end
ptype=regexp
pattern=ends \d (\w+ \w+);
action=eval %leaseend=( return "$1"; )

type=single
desc=dhcp ether address
ptype=regexp
pattern=hardware ethernet (\w+);
action=eval %ether=( return "$1"; )

type=single
desc=dhcp lease commit
ptype=regexp
pattern=}
action=spawn /usr/local/bin/leasetrack -ip %leaseip -mac %ether \
    -start %leasestart -end %leaseend









More information about the dhcp-users mailing list