Suppose I have more than a network interfaces and I want to selectively use them per application. eth0 is the standard interface with the standard gateway in the main routing table eth1 is another interface with a different gateway.
Suppose I launch an application as a user "user_eth1".
I used the following set of rules for iptables / ip rules.
iptables -t mangle -A OUTPUT -m user --uid-owner user_eth1 -j MARK --set-mark 100 iptables -t nat -A POSTROUTING -m user -uid-owner -o eth1 user_eth1 -j SNAT --to-source <eth_ipaddress>
ip rule add fwmark 100 lookup table100
and i build "table100" as follows (no doubts on that)
ip route show table main | grep -Ev ^default | while read ROUTE; do ip route add table table100 $ROUTE; done ip route add default via <default_gateway> table table100
It doesn't work at all. What's wrong with this?
Thank you in advance!