Help Required on RENEW/RELEASE through PERL script
mkparam at gmail.com
Wed Aug 8 12:53:30 UTC 2012
Reposting as i am not too sure it reached all the dhcp-users in this
mailing list. Please someone help. Thank you.
On Tue, Aug 7, 2012 at 9:35 PM, PARAM KRISH <mkparam at gmail.com> wrote:
> 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
> 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() =>
> 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_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 messages
> 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
> https://groups.google.com/forum/#!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...
More information about the dhcp-users