Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

I run RHEL 5 and have two NICs on one machine connected to the same subnet:

My application needs to receive and transmit UDP packets (both unicast & broadcast) via these interfaces. I've found the way to handle the ARP problem and I've added routes to handle the routing problem:
ip rule add from lookup 10
ip route add table 10 default src dev eth0
(and similarly, table 11 for eth1)

The problem is that only unicast packets gets routed properly. Broadcast packets always go out through eth0. I tried removing the rule for & from table 255 and adding them to my tables. But then I see ARP requests being given out for packets to (obviously, no nodes respond and nobody gets any data).

Due to several techno-political issues, I'm stuck with this configuration and can't change subnets or try something different. I've tried SO_BINDTODEVICE and it works, but I'd prefer a solution that doesn't need my application to run as root.

Is there a way to get this working? Any help is highly appreciated.

share|improve this question
if this is about link redundancy, why aren't you looking at channel bonding? –  Zoredache Feb 26 '11 at 13:41
@Zoredache Yes, so I read. But I'm pretty sure that the managers here wouldn't appreciate this. Here, we do pretty much everything in the application level, treating Ethernet interfaces like regular RS232 serial links :-( I'd appreciate it if I can get these broadcast packets also to go out through the interface specified by the application (by means of binding the socket). –  Syam Feb 27 '11 at 16:27
Can you use multicast for that? It will be pretty easy to set up routing and transmit the packet over selected interface using destination routing –  DukeLion Dec 19 '12 at 7:09

2 Answers 2

I must be missing something. How would proper routing behave for the broadcast packets? Just load-balance? If both interfaces are on the same subnet, and broadcasts are addressed to all devices on the subnet, does it really matter if all broadcasts come from one interface?

share|improve this answer
Well it matters in that we're having two NICs for redundancy. If one cable is out or if some reason the NIC has failed, we want to make sure that the packets still reach the network through the other one. My application will be sending the same UDP packet through both interfaces (most of the time broadcast, sometimes unicast too). –  Syam Feb 26 '11 at 5:36
To add, our aim is to have two network switches and machines with two network cards, each connected to one switch. This way, even if one of the switches fail, or if one of the NICs in any machine fails, we still have an operational system.The sad part is that I'm not allowed to put the two networks in different subnets. –  Syam Feb 26 '11 at 7:52
Aha! Have you looked into "NIC bonding" where the driver handles the redundancy? The NICs share a single IP. For example, cyberciti.biz/tips/… –  Paul Feb 26 '11 at 14:57
Thanks Paul. I had read about bonding a couple of days back, and technically, the 'broadcast' bonding mode might just work. But our 'conventional' managers might not want such a solution. They'd rather be comfortable with the management done by the application. I know I'm asking a little too much, but I'd really appreciate it if I can get it working like that. –  Syam Feb 27 '11 at 14:01
With reservation for that I don't understand you fully. Serial links are point-to-point, whereas ethernet is not. Bonding (active-passive, or something else if there's support in the switch(es) for it) will do the trick, and if you need a second ip just add that as an alias. –  3molo Sep 12 '12 at 10:26

I found a weird way of doing this. I'm not sure if this is portable. But it sure seems to work fine on Linux (2.6.18, to be exact).
If I send broadcast packets to the global broadcast address (instead of the subnet broadcast address), then the packets seem to go out through the interface corresponding to the originating socket, irrespective of the default route.

Can anybody confirm if this indeed is expected behaviour? I can't find anything useful on this by googling :-(

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.