Score:0

Make programs binded to other network interface use other gateway than default

ru flag
ndd

I would like for a program that binded to network interface that is not eth0 to use other default gateway when making connections.

ip rule add oif tun0 table 11
ip route add default via 10.3.33.20 table 11
ip route flush cache
ip rule list
0:      from all lookup local
32764:  from all iif tun0 lookup 11
32765:  from all oif tun0 lookup 11
32766:  from all lookup main
32767:  from all lookup default
ip route list table all
default via 10.3.33.20 dev tun0 table 11
default via 172.104.159.1 dev eth0 proto static metric 100
10.3.0.0/16 dev tun0 proto kernel scope link src 10.3.33.21
172.104.159.0/24 dev eth0 proto kernel scope link src 172.104.159.249 metric 100
...

When I bind program to interface tun0 it does not transmit antything to gateway 10.3.33.20

in flag
If the application is bound to specific if, then hopefully you can have a IP rule on the source IP. `ip rule add from $ip table 11`
ndd avatar
ru flag
ndd
Thanks. Yes, ip rule add from <tun0-interface-ip> table 11 works while ip rule add oif tun0 table 11 for some reason wont.
in flag
If I remember correctly, interface has not yet been determined, it is only decided after routing, oif probably works on things like modifying src ip in the route.
Score:0
ru flag
ndd

works:

ip rule add from <tun0-interface-ip> table 11 
ip route add default via 10.3.33.20 table 11
ip route flush cache

for some reason won't work:

ip rule add oif tun0 table 11
ip route add default via 10.3.33.20 table 11
ip route flush cache
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.