RENEW/RELEASE through PERL script

PARAM KRISH mkparam at
Thu Aug 9 15:00:18 UTC 2012

Anybody here to help me with this ?

I am trying to write a simple perl script that helps me sending DHCP
I have setup two VM's in a Vswitch and eth1 of VM1 works as dhcp server
with ISC DHCP 4.1.1-P1 on RHEL6 64-bit while the client VM1 is RHEL5 64bit
in which i am writing the perl script.
I am able to send the DHCPDISCOVER AND DHCPREQUEST, that gets me a valid IP
successfully. But the problems so far i observe are

1. Whenever i send a DHCPREQUEST, it gets me a new IP even though the lease
for the earlier request still remains valid. How do i get over this so that
it gets me the same IP that was last sent if the lease is not expired
otherwise can give me a new IP ? If i don't send a DHCPDISCOVER to send
DHCPREQUEST directly, it does not get through...

# create DHCP Packet REQUEST
$request = Net::DHCP::Packet->new(
                      #Xid =>  int rand(0xFFFFFFFF),
                      Xid => int(rand(0xFFFFFFFF)),
                      Chaddr => $MAC,
                      Ciaddr => '0',
                      Yiaddr => $response->yiaddr(),
                      Siaddr => $response->siaddr(),
                      Giaddr => $handle -> sockhost(),
                        DHO_DHCP_RENEWAL_TIME() => 24*60*60,

                      DHO_DHCP_MESSAGE_TYPE() => DHCPREQUEST(),
                      #DHO_VENDOR_CLASS_IDENTIFIER() => 'foo',
                      DHO_DHCP_REQUESTED_ADDRESS() => $response->yiaddr(),);

2. By Sending a LEASEQUERY, I get details like LEASE_TIME etc., to know how
long the lease is valid for a IP but if i need to RENEW or RELEASE this,
how do i do ? I am unable to achieve this when i attempt sending
DHCPFORCERENEW or DHCPRELEASE , both just hangs ? Do you guys have some
sample scripts to achieve this ?

3. While using LEASEQUERY, only if send IP, i get the details. How about
getting the details by sending MAC ? It did not work for me. I see messages
like these in the server...
DHCPLEASEQUERY from for MAC address 00:50:56:aa:bb:cc
DHCPLEASEUNKNOWN to for MAC address 00:50:56:aa:bb:cc (0
associated IPs)

I posted my problems earlier here!msg/comp.lang.perl.misc/T_7TsEBGjSk/BLeRRuArQ9wJuntil
i reached this level.
Now i require some help from you so that i can proceed writing end to end
solution through my script that can be used for our internal dhcp

Thanks in-advance.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <>

More information about the dhcp-users mailing list