How to route broadcast packets from machine with two network interfaces on same subnet
- by Syam
I run RHEL 5 and have two NICs on one machine connected to the same subnet:
eth0 192.168.100.10
eth1 192.168.100.11
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 192.168.100.10 lookup 10
ip route add table 10 default src 192.168.100.10 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 192.168.100.0 & 192.168.100.255 from table 255 and adding them to my tables. But then I see ARP requests being given out for packets to 192.168.100.255 (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.