#!/usr/bin/perl -w
#
# This'll create dhcpd.conf strings from cisco-2924 (or compatible) 
# 'show running-config' output (just from a downloaded cisco config if 
# confused).
#
# License is current GNU one.
# Originally by rserg@mtcm.ru. Rewriten by Light Olli <olli@digger.org.ru>
#
use strict;
my ($mac,$ip,$last_ip);
$mac=$ip=$last_ip=undef;
while( <STDIN> )
{if ( /arp (\S+) (\S+) arpa/i ) 
 {$ip = $1; $mac = $2;
 if ( $ip =~ /\.(\d+)$/ ) {$last_ip = $1}
 if ($mac =~ /(..)(..).(..)(..).(..)(..)/i)
  {print " host host$last_ip { hardware ethernet $1:$2:$3:$4:$5:$6; fixed-address $ip; option host-name \"host$last_ip\"; }\n"}
}}
close STDIN;

