How to broadcast to 255.255.255.255 on non-default interface
How to broadcast to 255.255.255.255 on non-default interface
- Subject: How to broadcast to 255.255.255.255 on non-default interface
- From: Craig Carrier <email@hidden>
- Date: Sat, 07 Mar 2009 14:04:22 -0500
- Thread-topic: How to broadcast to 255.255.255.255 on non-default interface
I'm trying to do a UDP broadcast to the 255.255.255.255 address to all
interfaces. The problem is that the broadcast will only be sent out the
default(primary) interface. Nothing ever shows up on the other interface.
As far as I can tell this is how the IP layer will route it even though the
socket was bound to the address of the interface. I can broadcast to a
limited address (ie. 192.168.50.255) and it will be sent out the other
interface(not default).
Here's the info on the two interfaces..
eth0: 10.0.1.20 netmask 255.255.255.0
eth1: 192.168.50.2 netmask 255.255.255.0
eth0 is set as the primary in the network config panel and needs to stay
this way as it's the path to the internet. eth1 is the interface to a
network of devices that all respond to broadcasts with their addresses in
the reply. The devices live in the 10.x.x.x (netmask 255.0.0.0) realm.
Work-arounds (that are less than desirable to instruct a user though)
1. Manually change the address of eth1 to be in the 10.x.x.x subnet and
broadcast to 10.255.255.255 in the app
2. Change the service order manually and disable access to the internet
while connected to the devices and broadcast to 255.255.255.255
3. Create another service attached to eth1 with an address on the 10.x.x.x
subnet and broadcast to 10.255.255.255
No. 3 is the best I've got so far, but I'd have to automate this process
somehow which would also require admin privileges *frown*.
Ideally I'd like to force the broadcast to route down the interface of the
user's discretion, but that *force* part is what I'm missing. I was hoping
that the MSG_DONTROUTE of send() and sendto() would be the magic, but when
sending I get notified that the network is unreachable.
How does a DHCP server do this. It must be able to send broadcasts down a
chosen interface other than the default one.
Any help is greatly appreciated.
-Craig
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Macnetworkprog mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden