robertlandrum has asked for the wisdom of the Perl Monks concerning the following question:
I'm using perl to send broadcast packets back to DHCP Clients. I'm listening on a address bound to eth1. When I broadcast my packets, they go out on eth0.
I've played with route (based on old dhcp instructions), to try and get the kernel to route 255.255.255.255 to eth1, but nothing seems to have worked so far.
One thing that does work is ISC DHCPD. It does not change the host's routes, but does manage to broadcast packets on the correct interface. I intially suspected that this was done using ioctl, but after grepping through the code, can't put my finger on exactly where they tell the socket (and by extension, the kernel) which interface to use when broadcasting.
Anyone ever done this before? What's the solution?
You have not specified if you use the same socket for listening and sending. This advice is relevant in case they are different:
You can specify a particular ethernet interface by specifying the IP address (other than INADDR_ANY) in the socket
bind command, even for SEND sockets.
"As you get older three things happen. The first is your memory goes, and I can't remember the other two... "
- Sir Norman Wisdom