I have a system with two network interfaces, both connecting to same default gateway. I want to load balance the connections to the same destination IP made from the system across both interfaces and use source IPs from each. I want this solution to be generic and work for whatever program we run in the system. What I've observed till now, is that linux maintains a mini routing cache, so once the first few connections are established, locks on to one route.. so the initial few connections are distributed across source IPs of two interfaces, but ultimately converges to one of them(I'm guessing there's some logic to lock on to deciding which route is better than other in case of conflicts)
Using iptables will influence the packet only after the initial routing decision is made and source IP is selected. Is there any way whatsoever to influence the source IP selection of socket to load balance across multiple interfaces?
UPDATE: I came across eBPF that can modify socket properties, can this be leveraged to modify source address in round robin across all available interfaces (except loopback)