All
I know this is a pretty old thread, but looks like i hit the exact same problem this week while trying to use DHCP:

acket.
My requirement is that i want to use this perl module to get the IP's from DHCP server to do some PoC. I have two VM's , one act as DHCP server (RHEL564bit), and another RHEL5 64bit to run this script to get IP's from the DHCP server , both having two interfaces eth0 and eth1; eth1 of both the VM'sconnected to a VMware VSwitch to isolate these two VM's from others; eth0 of both the VM's having a valid IP in the range 10.72.x.x ; DHCP server listens on eth1 from the first VM.
When i use a script like this one, i can see the DHCPDISCOVER is sent properly as it reaches the server and DHCPOFFER is also being made by the serveras per the logs ; but my script does not pick up the packet for some reasons which i am unable to understand.
--script --
#!/usr/bin/perl
# Simple DHCP client - sending a broadcasted DHCP Discover request
use IO::Socket::INET;
use Net:

HCP:

acket;
use Net:

HCP::Constants;
use POSIX qw(setsid strftime);
# sample logger
sub logger{
my $str = shift;
print STDOUT strftime "[%d/%b/%Y:%H:%M:%S] ", localtime;
print STDOUT "$str\n";
}
logger("DHCPd tester - dummy client");
logger("Opening socket");
$handle = IO::Socket::INET->new(Proto => 'udp',
Broadcast => 1,
PeerPort => 67,
LocalPort => 68,
LocalAddr => '192.168.1.3',
PeerAddr => '255.255.255.255')
|| die "Socket creation error: $@\n"; # yes, it uses $@ here
# create DHCP Packet DISCOVER
$discover = Net:

HCP:

acket->new(
Xid => 0x12345678,
Flags => 1,
Chaddr => '0050569821A9',
DHO_DHCP_MESSAGE_TYPE() => DHCPDISCOVER(),
DHO_VENDOR_CLASS_IDENTIFIER() => 'foo',
);
logger("Sending DISCOVER to 192.168.1.2:67");
logger($discover->toString());
$handle->send($request->serialize())
or die "Error sending:$!\n";
logger("Waiting for response from server");
$handle->recv($buf, 4096) || die("recv:$!");
logger("Got response");
$response = new Net:

HCP:

acket($buf);
logger($response->toString());
-- /var/log/messages of DHCP Server ---
Jul 26 22:21:03 vmlnx64-30 dhcpd: DHCPDISCOVER from 00:50:56:98:21:a9 via eth1
Jul 26 22:21:03 vmlnx64-30 dhcpd: DHCPOFFER on 192.168.1.49 to 00:50:56:98:21:a9 via eth1
** TCPDUMP of DHCP Server and Client when this is being run ***
DHCPSERVER
**********
dhcp-Server>tcpdump -i eth1 -vvv
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
17:40:27.555097 IP (tos 0x0, ttl 1, id 0, offset 0, flags [none], proto: IGMP (2), length: 36, options ( RA (148) len
4 )) 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
17:40:27.634538 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4
)) 192.168.1.2 > igmp.mcast.net: igmp v3 report, 1 group record(s) [gaddr 224.0.0.251 is_ex { }]
17:40:33.120044 IP (tos 0x0, ttl 64, id 2290, offset 0, flags [DF], proto:UDP (17), length: 328) 192.168.1.3.bootpc >
255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:56:98:23:8d (oui Unknown), length: 300, xid:0x12345678, flags: [none] (0x0000)
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:40:33.121657 arp who-has 192.168.1.50 tell 192.168.1.2
17:40:34.001555 IP (tos 0x10, ttl 16, id 0, offset 0, flags [none], proto:UDP (17), length: 328) 192.168.1.2.bootps > 192.168.1.50.bootpc: BOOTP/DHCP, Reply, length: 300, xid:0x12345678, flags: [none] (0x0000)
Your IP: 192.168.1.50
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:40:34.122468 arp who-has 192.168.1.50 tell 192.168.1.2
17:40:34.554985 IP (tos 0x0, ttl 1, id 0, offset 0, flags [none], proto: IGMP (2), length: 36, options ( RA (148) len 4 )) 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
17:40:34.585378 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4 )) 192.168.1.2 > igmp.mcast.net: igmp v3 report, 1 group record(s) [gaddr 224.0.0.251 is_ex { }]
17:40:35.122279 arp who-has 192.168.1.50 tell 192.168.1.2
17:41:06.957198 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:06.957210 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:06.957211 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:06.957223 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:07.556639 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:07.630083 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4 )) 192.168.1.3 > igmp.mcast.net: igmp v3 report, 1 group record(s) [
gaddr 224.0.0.251 is_ex { }]
17:41:08.558188 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:09.557206 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:09.706661 IP (tos 0x0, ttl 64, id 38874, offset 0, flags [DF], proto: UDP (17), length: 328) 192.168.1.3.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:56:98:23:8d (oui Unknown), length: 300, xid:0x12345678, flags: [none] (0x0000)
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:41:09.706840 IP (tos 0x10, ttl 16, id 0, offset 0, flags [none], proto:UDP (17), length: 328) 192.168.1.2.bootps > 192.168.1.50.bootpc: BOOTP/DHCP,
Reply, length: 300, xid:0x12345678, flags: [none] (0x0000)
Your IP: 192.168.1.50
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:41:11.556846 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:14.557189 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:14.643834 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4 )) 192.168.1.3 > igmp.mcast.net: igmp v3 report, 1 group record(s) [
gaddr 224.0.0.251 is_ex { }]
17:41:19.557221 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:27.559216 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
17:41:40.558913 rarp who-is 00:50:56:98:23:8d (oui Unknown) tell 00:50:56:98:23:8d (oui Unknown)
DHCP CLIENT
***********
dhcp-Client>tcpdump -i eth1 -vvv
tcpdump: listening on eth1, link-type EN10MB (Ethernet), capture size 96 bytes
17:41:07.553418 IP (tos 0x0, ttl 1, id 0, offset 0, flags [none], proto: IGMP (2), length: 36, options ( RA (148) len 4 )) 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
17:41:07.626696 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4 )) 192.168.1.3 > igmp.mcast.net: igmp v3 report, 1 group record(s) [gaddr 224.0.0.251 is_ex { }]
17:41:09.703284 IP (tos 0x0, ttl 64, id 38874, offset 0, flags [DF], proto: UDP (17), length: 328) 192.168.1.3.bootpc > 255.255.255.255.bootps: BOOTP/DHCP, Request from 00:50:56:98:23:8d (oui Unknown), length: 300, xid:0x12345678, flags: [none] (0x0000)
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:41:09.703796 IP (tos 0x10, ttl 16, id 0, offset 0, flags [none], proto:UDP (17), length: 328) 192.168.1.2.bootps > 192.168.1.50.bootpc: BOOTP/DHCP, Reply, length: 300, xid:0x12345678, flags: [none] (0x0000)
Your IP: 192.168.1.50
Client Ethernet Address: 00:50:56:98:23:8d (oui Unknown) [|bootp]
17:41:14.553952 IP (tos 0x0, ttl 1, id 0, offset 0, flags [none], proto: IGMP (2), length: 36, options ( RA (148) len 4 )) 10.0.0.0 > all-systems.mcast.net: igmp query v3 [max resp time 1s]
17:41:14.640463 IP (tos 0xc0, ttl 1, id 0, offset 0, flags [DF], proto: IGMP (2), length: 40, options ( RA (148) len 4 )) 192.168.1.3 > igmp.mcast.net: igmp v3 report, 1 group record(s) [gaddr 224.0.0.251 is_ex { }]
17:41:21.554244 rarp who-is 00:50:56:98:04:36 (oui Unknown) tell 00:50:56:98:04:36 (oui Unknown)
There is no iptables as i can verify.
Any help to figure out why my script unable to receive the DHCP Offer Packets(that has the Your_IP details )would be much appreciated. Thanks for the help.
PK