RENEW/RELEASE through PERL script
glenn.satchell at uniq.com.au
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
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
> packets like DHCPDISCOVER, REQUEST,RENEW,RELEASE.
> 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
> successfully. But the problems so far i observe are
> 1. Whenever i send a DHCPREQUEST, it gets me a new IP even though the
> for the earlier request still remains valid. How do i get over this so
> 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() =>
> 2. By Sending a LEASEQUERY, I get details like LEASE_TIME etc., to know
> 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_MESSAGE_TYPE(53) = DHCPLEASEACTIVE
> DHO_DHCP_SERVER_IDENTIFIER(54) = 192.168.1.2
> DHO_DHCP_LEASE_TIME(51) = 2153
> DHO_SUBNET_MASK(1) = 255.255.255.0
> DHO_ROUTERS(3) = 192.168.1.0
> DHO_DHCP_RENEWAL_TIME(58) = 653
> DHO_DHCP_REBINDING_TIME(59) = 1778
> DHO_CLIENT_LAST_TRANSACTION_TIME(91) = \x00\x00\x03O
> 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
> like these in the server...
> DHCPLEASEQUERY from 192.168.1.3 for MAC address 00:50:56:aa:bb:cc
> DHCPLEASEUNKNOWN to 192.168.1.3 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
> Thanks in-advance.
> dhcp-users mailing list
> dhcp-users at lists.isc.org
More information about the dhcp-users