I want to decide on application level which gateway to use to connect to the internet.
It can't be done by simple subnet rules, because it is really the application which should be able to decide which gateway to use.
E.g. I want to use curl to download something and I want to specify somehow which gateway to use.
It is a Linux box having only one network card, IP address 10.0.0.1. There are two or more gateways (different ISPs): e.g. 10.0.0.100 and 10.0.0.101.
Is it possible to set up routing rules with iptables and iproute2 to manage that? How do I tell an application which route to use?
I tried this:
I added in /etc/iproute2/rt_tables: 100 out2
ip rule add prio 200 from 10.0.0.2 lookup out2
ip route add 10.0.0.0/24 dev eth0 src 10.0.0.2 table out2
ip route add default via 10.0.0.100 dev eth0 src 10.0.0.2 table out2
Still "telnet -b 10.0.0.2 www.google.com 80" returns "network is unreachable"