How to alter the global broadcast address (255.255.255.255) behavior on Windows?
Not that I am in the business of defending Microsoft, but after reading through the following RFCs which attempt to define how broadcasts work, I don't think that Microsoft is necessarily violating any RFCs. IMO the problem should be fixed at the application level (i.e. directed broadcasts, not global) which will hit the appropriate routes in the routing table and only be sent from the correct interface for that IP network.
- RFC922
- RFC919
They both state that there is no standard defined for broadcasts. It also mentions in 919 that a specific physical interface should be selected for the broadcast. In the case of a multi-homed, multi-NIC machine generating the broadcast, I don't think that it's clearly stated what should happen. Broadcasts are never supposed to be passed by routers from one interface to the other, so is the Windows machine a router or not in this case?
If it is acting as a router, then any host responding to the broadcast with the incorrect IP address for that network (Adapters 2 and 3 in your example) should send the packet back to the ethernet address of Adapters 2 and 3 in response to Adapter 1's IP address and the Windows host should route it to the proper interface.
That sounds confusing... but can't think of a better way to phrase this
And finally, RFC 919 specifically says From RFC 919
Since we assume that the problem has already been solved at the data link layer, an IP host wishing to
send either a local broadcast or a directed broadcast need only
specify the appropriate destination address and send the datagram as
usual. Any sophisticated algorithms need only reside in gateways.
Reading that would suggest that the source IP address is irrelevant for a broadcast.
Since each application seems to handle broadcasts differently, I think that's where the responsibility resides. For example. nbtstat
sends out directed broadcasts on multi-NICed machines, whereas games might use global broadcasts.
In short, the application should be fixed, not the OS in this case...
EDIT: Here is a link for the same circumstances, but on Linux. The linux kernel handles it by only sending one packet out the default interface (NIC A in this example). They recommend that the application enumerate the NICs and send a directed broadcast out each NIC. Link
Finally, I solved it programmatically. I wrote a tiny software called WinIPBroadcast which takes care of relaying the broadcast frames to all interfaces.
It works using an interesting fact: it is possible to receive locally generated global broadcast packets when listening on the loop back address (127.0.0.1). WinIPBroadcast listens on the local address for all broadcast using RAW sockets, then for each broadcast packet, it relays it to all interfaces except the preferred one.
Update 06.12.2021: Updated Link for the community