#!/usr/bin/perl # ^ Change this to /bin/perl on mcp # Take the name database and generate a DHCP table from it. # This script reads the hosts file on stdin and dumps dhcpd.conf to stdout. # For normal use, this means dhcpgen < /etc/namedb/csh-hosts > /etc/dhcpd.conf # (c) 2000 Joe Sunday. All Rights Reserved. # This program is licensed under the terms of version 2 or at the user's # option, any later version of the GNU Public License from www.gnu.org. # Edit this block to change any of the global options for dhcp. print << "HEAD"; # dhcpd.conf # autogenerated from csh-hosts option domain-name "csh.rit.edu"; option domain-name-servers mcp.csh.rit.edu; subnet 129.21.60.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option routers 129.21.60.254; default-lease-time 3600; max-lease-time 7200; # The dynamic block of addresses. range 129.21.60.216 129.21.60.230; } HEAD while( ) { # Attempt to get a hostname, mac address and username(optional) from # the input line. Look for an alphanumeric followed by a space, # then anything, then a mac address, then " - username". if( /^([\w\-]+)\s.*([A-Fa-f\d\:]{17})\s\-?\s([\w]*)/ ){ my $hostname = $1; my $mac = $2; my $user = $3; if( $user ) { print( "# $user\n" ); } print "host $1 {\n"; print " hardware ethernet $mac;\n"; print " fixed-address $1.csh.rit.edu;\n"; print "}\n\n"; } }