RENEW/RELEASE through PERL script

Glenn Satchell glenn.satchell at
Fri Aug 10 02:58:38 UTC 2012


Not sure I have a perfect answer here, but for protocol level things like
this the Core DHCP RFC-2131 is probably a good reference.

I have a feeling you need to send the response id (rid?) for subsequent
DHCPREQUEST but I'm not 100% sure about that so reading the appropriate
section RFC is probably the best idea. There are some very useful files to
read in the doc subdirectory of the source distribution.

Also make sure you either don't use the Client-id, or use it consistently
all the time. The ISC dhcp server recognises a client by the client-id
first, and then falls back to mac address. A request with the same mac
address, but different (or one missing) client-id will be seen as two
different clients.


On Fri, August 10, 2012 1:00 am, PARAM KRISH wrote:
> 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 ?
> ...
>  DHO_DHCP_LEASE_TIME(51) = 2153
> ...
> 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
> 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
> requirement..
> Thanks in-advance.
> _______________________________________________
> dhcp-users mailing list
> dhcp-users at

More information about the dhcp-users mailing list