PHP Classes

File: LeaseQuery.php

Recommend this page to a friend!
  Classes of Pat Winn   DHCP Lease Query   LeaseQuery.php   Download  
File: LeaseQuery.php
Role: Example script
Content type: text/plain
Description: Sample Code - How To Use
Class: DHCP Lease Query
Send queries to a DHCP server
Author: By
Last change: Made accessible to those without a login.
Date: 8 years ago
Size: 1,282 bytes
 

Contents

Class file image Download
<?php

/**
 * A simple test script to demonstrate how to use the dhcpLeaseQuery class.
 * Please read the note below first then edit the variables below as appropriate.
 * Then simply run: php LeaseQuery.php
 *
 * Note: ISC's dhcpd will *NOT* listen for LeaseQuery packets on the same system
 * it is running on. Not even on the local loopback. This is because the LeaseQuery
 * packet is intended to be sent from a true DHCP Relay such as a router or access server.
 * Thus, make certain that you are running this from a different system other than the
 * dhcp server itself and set the $gi variable to the IP of the box you are running this
 * from. (if on a multi-homed system, be sure to set it to the IP you will be sending
 * from).
 *
 * If this file looks funky to you, try setting tab stops=4.
 *
 * @author Pat Winn (pat@patwinn.com)
 * @date 10/16/2010
 * @version 1.0
 */

require_once('dhcpLeaseQuery.php');

$gi = "x.x.x.x"; // dhcp relay ip
$sv = "x.x.x.x"; // dhcp server ip to send query to
$ci = "x.x.x.x"; // IP address to ask server about

$lq = new dhcpLeaseQuery($gi, $sv);

if(
$lq->sendQuery($ci)) {
   
$lease = $lq->receive();
    if(
$lease !== false) {
        echo
"\nLease Info We Got Back:\n";
       
print_r($lease);
    }
}

?>