From: Clark, Bobby (Bobby.Clark@eku.edu)
Date: Mon Sep 03 2001 - 03:07:06 CDT
I did some research into the lease parsing problems.
I am using dhcp-3.0rc12. It comes with the program "omshell" which is a
shell for the omapi protocol.
Add 'omapi-port 7911' to the dhcpd.conf You will probably want to use the
omapi-key option as well, but I have left that out.
in the end this doesn't require dhcpd to be restarted
#--------------------------------getlease.pl---------------#
#!/usr/bin/perl
# getlease.pl
# by: Bobby Clark (bobby.clark@eku.edu)
# purpose: return lease information from isc dhcpd using omshell (omapi)
# usage: getlease.pl ipaddress
# example: getlease.pl 192.168.0.130
$ipaddress = @ARGV[0];
open(OMSHELL, "/usr/bin/omshell") || die("Could not open omshell\n");
print OMSHELL "connect\n";
print OMSHELL "new lease\n";
print OMSHELL "set ip-address = $ipaddress\n";
print OMSHELL "open\n";
close(OMSHELL) || die("Could not close omshell\n");
exit(0);
#--------------------------------getlease.pl---------------#
Now.....
register.cgi changes
#---------------------------------------------------------------------------
-\
# The User has authenticated, get their network & hardware info
#---------------------------------------------------------------------------
-\
sub get_host_info {
# modified by: Bobby Clark (bobby.clark@eku.edu)
# depends on getlease.pl
open(GETLEASE, "getlease.pl $IP | ") || error("Could not open
getlease\n");
while (<GETLEASE>) {
if ($_ =~ m/hardware-address/) {
($key, $val) = split(' = ');
chomp($val); # This is the macaddress
$RECORDS{$IP} = $val;
}
}
}
close(GETLEASE) || error("Could not close getlease\n");
if (!exists ($RECORDS{$IP})) {
error("No Lease Found");
}
}
#---------------------------------------------------------------------------
-/
I will be working on using omshell for creating host definitions, but the
happens only in the lease file, so it will break admin.cgi for the time
being.
looks something like this.
open(OMSHELL,"| /usr/bin/omshell") || error("Could not open omshell");
print OMSHELL "connect\n";
print OMSHELL "new host\n";
print OMSHELL "set name = \"$FORM{'user'}\"\n";
print OMSHELL "set hardware-address = $RECORDS{$IP}\n";
print OMSHELL "set hardware-type = 1\n"; # ethernet
print OMSHELL "create\n"; # save in dhcpd.leases
close(OMSHELL) || error("Could not close omshell");
Bobby Clark
bobby.clark@eku.edu
Data Services Engineer
Eastern Kentucky University
ps. I have done this brainstorming without the benefit of my test
environment, so please excuse any stupid typo's.
**********************************************************************
To unsubscribe from this list, send an e-mail message to
majordomo@southwestern.edu containing a single line with the words:
unsubscribe netreg
Send requests for assistance to: owner-netreg@southwestern.edu
**********************************************************************
This archive was generated by hypermail 2.1.4 : Thu Aug 12 2004 - 12:01:36 CDT