in reply to Re^3: Figuring out which network interface a broadcast packet came in on?
in thread Figuring out which network interface a broadcast packet came in on?

Routing tables aren't very useful for DHCP packets, because a significant proportion of DHCP packets don't have unique IP addresses even at a local network level. After all DHCP is typically used by hosts without valid IP addresses to get valid IP addresses.

getsockopt and setsockopt allow you to get more info about a socket. e.g.

# Get the original destination of the connection # that was redirected to our socket my $p= getsockopt $client, $SOL_IP, $SO_ORIGINAL_DST; $orig_destaddr=inet_ntoa(substr($p,4,4)); $orig_destport=unpack('n',substr($p,2,2));
I just don't know how to read or write the ancillary messages once I set the IP_PKTINFO socket option. In C it's stuff like sendmsg, recvmsg or cmsg.

DHCP doesn't really require high performance - legitimate client machines should not be sending DHCP packets at a high rate, so perl isn't such a bad fit other than this problem I'm having. A perl DHCP server won't be as prone to buffer overflows and will be flexible and more easily extensible.

  • Comment on Re^4: Figuring out which network interface a broadcast packet came in on?
  • Download Code