DHCP server

Discussion in 'Perl Misc' started by Andy Rabagliati, Dec 24, 2006.

  1. Folks,

    I am trying to make http://unixgu.ru/tmp/ctf-dhcpd/test.pl work, as I
    need a DHCP server that can pull the leases from LDAP.

    The ldap patches to the ISC DHCP server also do not work for me,
    but the schema seems way too complicated in that case also.

    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 in question is sendAnswer below. I usually have a
    firewall on this machine, but it is configured to accept any traffic
    from the LAN.

    A regular DHCP server works, and I have tried turning the firewall
    off, without success.

    Any ideas ?

    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() ) {
    $answer->addOptionValue(
    DHO_DOMAIN_NAME_SERVERS(),
    $Config{ 'dhcp' }{ 'dnsServer' }
    ) if $Config{ 'dhcp' }{ 'dnsServer' };
    $answer->addOptionValue(
    DHO_ROUTERS(),
    $Config{ 'dhcp' }{ 'defaultRoute' }
    ) if $Config{ 'dhcp' }{ 'defaultRoute' };
    }

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

    print "</sendAnswer>\n";
    }
    Andy Rabagliati, Dec 24, 2006
    #1
    1. Advertising

  2. On Sun, 24 Dec 2006 05:25:57 -0800, Andy Rabagliati wrote:

    > Folks,
    >
    > I am trying to make http://unixgu.ru/tmp/ctf-dhcpd/test.pl work, as I
    > need a DHCP server that can pull the leases from LDAP.
    >
    > The ldap patches to the ISC DHCP server also do not work for me,
    > but the schema seems way too complicated in that case also.
    >
    > 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 in question is sendAnswer below. I usually have a
    > firewall on this machine, but it is configured to accept any traffic
    > from the LAN.
    >
    > A regular DHCP server works, and I have tried turning the firewall
    > off, without success.


    Start wireshark (formerly ethereal) and look at the differences from a
    working DHCP server and yours.

    HTH,
    M4
    --
    Redundancy is a great way to introduce more single points of failure.
    Martijn Lievaart, Dec 25, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Katie Wright
    Replies:
    2
    Views:
    2,672
    Steve Horsley
    Aug 28, 2003
  2. GHUM
    Replies:
    0
    Views:
    436
  3. Replies:
    1
    Views:
    367
    Victor Bazarov
    Apr 8, 2007
  4. Aldric Giacomoni

    Ruby and DHCP (Net::DHCP maybe)

    Aldric Giacomoni, Dec 5, 2008, in forum: Ruby
    Replies:
    1
    Views:
    311
    Eustáquio Rangel
    Dec 5, 2008
  5. Chris Henderson

    detect rogue DHCP server

    Chris Henderson, Mar 17, 2009, in forum: Ruby
    Replies:
    4
    Views:
    186
    Joel VanderWerf
    Mar 17, 2009
Loading...

Share This Page