LDAP backend to dhcpd

Andy Rabagliati andyr at wizzy.com
Sun Dec 24 15:29:34 UTC 2006


  It seems to me that the schema for the dhcpd-ldap patches are more
  oriented at replicating the dhcpd conf file than a clean schema of
  what is needed.

  For instance, dhcpHWAddress is not just the MAC address, but it is
  "ethernet 00:12:3f:8d:f5:0e" - to re-create the dhcpd.conf file.

  Things like pools and options follow the same pattern.

  I would like a set of patches that will read LDAP entries like

dn: cn=waxbill,ou=Computers,dc=aims,o=aims
cn: waxbill
objectClass: ipHost
objectClass: dhcpHost
dhcpHWAddress: 00:12:3f:8d:fd:29

  with no other containers necessary.

  I looked at http://unixgu.ru/tmp/ctf-dhcpd/test.pl and the
  Net::DHCP perl modules, which also comes with an example DHCP server
  script, but as yet cannot get them to work.
  I have the LDAP lookups working, and sendAnswer (in the perl script)
  says it is working, but my clients do not receive an answer.

  The routine follows - is there anything obviously missing that would
  cause the client to not receive the reply ?

Cheers,  Andy!

sub sendAnswer {
        my( $type, $xid, $mac, $ip, $hostname ) = ( $_[0], $_[1], $_[2], $_[3], $_[4] );
print "<sendAnswer> type=$type, xid=$xid, mac=$mac, ip=$ip, hostname=$hostname\n";
        return unless $type and $mac and $ip;

        my $answer = Net::DHCP::Packet->new(
                'Op'                    => 2,
                'flags'                 => 0x8000,
                'Xid'                   => $xid,
                DHO_DHCP_MESSAGE_TYPE() => $type,
                'Yiaddr'                => $ip,
                'Chaddr'                => $mac
        $answer->addOptionValue( DHO_HOST_NAME(), $hostname ) if $hostname;

        if( $type eq DHCPACK() ) {
                                $Config{ 'dhcp' }{ 'dnsServer' }
                        ) if $Config{ 'dhcp' }{ 'dnsServer' };
                                $Config{ 'dhcp' }{ 'defaultRoute' }
                        ) if $Config{ 'dhcp' }{ 'defaultRoute' };

        $Sock->send( $answer->serialize() )
                or &handleError( 'Can\'t send answer:', $! );

print "</sendAnswer>\n";

More information about the dhcp-users mailing list