Well, DISCOVER is semantically similar to INFORM. Actually I think it started with INFORM, and at some point it morphed into DISCOVER. Use of > 1023 as the local port was to avoid permission problems on Unix boxes. I reasoned that I should be able to ask for a reply on any port I want, no?
So I changed the message type to INFORM and the LocalPort to 67 or 68:
my $socket = IO::Socket::INET->new(Proto => 'udp',
Broadcast => 1,
PeerPort => '67',
LocalPort => '68',
PeerAddr => '255.255.255.255')
or die ($@);
# create and send DHCP Packet
my $disc = Net::DHCP::Packet->new(xid => int(rand(0xFFFFFFFF)),
DHO_DHCP_MESSAGE_TYPE() => DHCPINFORM())
or die "Can't create DHCP discover packet: $!";
$socket->send($disc->serialize())
or die "Can't send DHCP discover packet: $!";
my @ready = IO::Select->new($socket)->can_read(5);
if (@ready) {
my $newmsg;
$socket->recv($newmsg, 1024)
or die "Can't recv DHCP discover packet: $!";
But those changes don't result in receiving a reply, nor does inserting or removing the Flags => 0x8000, in the Packet->new call.
Stepping through these has taught that nothing happens until the send call, at which time we get the following on tcpdump:dual-1-25:~ $ sudo tcpdump -evvv
tcpdump: listening on en0, link-type EN10MB (Ethernet), capture size 9
+6 bytes
19:18:21.323270 00:03:93:ab:f2:44 (oui Unknown) > Broadcast, ethertype
+ IPv4 (0x0800), length 342: (tos 0x0, ttl 64, id 11213, offset 0, fla
+gs [none], proto UDP (17), length 328) 192.168.1.2.bootps > broadcast
+host.bootps: BOOTP/DHCP, Request from 00:00:00:00:00:00 (oui Ethernet
+), length 300, xid 0x12345678, Flags [Broadcast] (0x8000)
19:18:21.335493 00:24:01:47:07:41 (oui Unknown) > Broadcast, ethertype
+ IPv4 (0x0800), length 314: (tos 0x0, ttl 64, id 0, offset 0, flags [
+none], proto UDP (17), length 296) 192.168.1.1.bootps > broadcasthost
+.bootpc: BOOTP/DHCP, Reply, length 268, xid 0x12345678, Flags [Broadc
+ast] (0x8000)
19:18:22.154360 00:03:93:ab:f2:44 (oui Unknown) > 00:24:01:47:07:41 (o
+ui Unknown), ethertype IPv4 (0x0800), length 84: (tos 0x0, ttl 64, id
+ 5403, offset 0, flags [none], proto UDP (17), length 70) 192.168.1.2
+.52733 > 192.168.1.1.domain: [udp sum ok] 8378+ PTR? 2.1.168.192.in-a
+ddr.arpa. (42)
19:18:22.194739 00:24:01:47:07:41 (oui Unknown) > 00:03:93:ab:f2:44 (o
+ui Unknown), ethertype IPv4 (0x0800), length 88: (tos 0x0, ttl 248, i
+d 47363, offset 0, flags [DF], proto UDP (17), length 70) 192.168.1.1
+.domain > 192.168.1.2.52733: [udp sum ok] 8378 NXDomain q: PTR? 2.1.1
+68.192.in-addr.arpa. 0/0/0 (42)
19:18:22.201699 00:03:93:ab:f2:44 (oui Unknown) > 00:24:01:47:07:41 (o
+ui Unknown), ethertype IPv4 (0x0800), length 84: (tos 0x0, ttl 64, id
+ 7025, offset 0, flags [none], proto UDP (17), length 70) 192.168.1.2
+.52029 > 192.168.1.1.domain: [udp sum ok] 21785+ PTR? 1.1.168.192.in-
+addr.arpa. (42)
19:18:22.242546 00:24:01:47:07:41 (oui Unknown) > 00:03:93:ab:f2:44 (o
+ui Unknown), ethertype IPv4 (0x0800), length 88: (tos 0x0, ttl 248, i
+d 23813, offset 0, flags [DF], proto UDP (17), length 70) 192.168.1.1
+.domain > 192.168.1.2.52029: [udp sum ok] 21785 NXDomain q: PTR? 1.1.
+168.192.in-addr.arpa. 0/0/0 (42)
19:18:27.190310 00:24:01:47:07:41 (oui Unknown) > 00:03:93:ab:f2:44
Can anyone see anything from this?
cmac
|