Ip rule add from interface This can be done one-time (non-persistent) as follows: ip rule add from 192. Each packet from the real IP is translated to the NAT IP without altering the destination address of the packet. ip rule add nat is used to rewrite the source IP on packets during the routing stage. from : Indicates that the rule applies to packets from a specified source address. 192. 34 ip route add table 80 default via 192. Classic routing algorithms used in the Internet make routing decisions based only on the destination address. ip rule manipulates rules in the routing policy database control the route selection algorithm. 20 table main ip route add default via 192. 101. 0/24 dev bond0 src 192. 1 You can make these be created when the interface goes up by adding up ip rule add from <interface_IP> table isp2 and up ip route add default via <gateway_IP> dev ppp0 table isp2 to your /etc/network/interfaces under the relevant interface. 1 dev eth0 table main ip rule add from 192. 1. I can easily mark matched packets: Please scratch any ip rule rules or iptables rules previously added to try and solve this problem. ip rule add - insert a new rule ip rule delete - delete a rule type TYPE (default) the type of this rule. inet addr:19. of packets (and in theory, but not in practice, on the TOS field). nat - the rule translates the source address of the IP packet into some other value. 168. So it's good practice to define the rules on both interfaces. 86. Keep the table 80 as in OP: ip route add table 80 192. 5. 2/32 : The specific source address in CIDR notation to which the rule applies. 255 Mask:255. 50. 0. from PREFIX select the source prefix to match To route the incoming and outgoing traffic through eth1, other than the default route (eth0), you also need to add additional routes for eth1 . I had to issue these commands in reverse order: 1st sudo ip route add default via <router-addr> dev <device-name> table <table-id>, 2nd sudo ip rule add from <source-addr>/<mask> lookup <table-id>. I'd like to use iptables to force all packets generated by a local process owned by UID 1002 to exit through tun0, and all other packets to exit through eth1. You can make these be created when the interface goes up by adding up ip rule add from <interface_IP> table isp2 and up ip route add default via <gateway_IP> dev ppp0 table isp2 to your /etc/network/interfaces under the relevant interface. 5 table mgmt ip route add default via 192. ip rule add: Specifies the addition of a new rule. 20. You can view your current ip-address of your interface cards using ifconfig command as shown below. 1 dev eth1 table mgmt The two components are ip route add nat and ip rule add nat. The list of valid types was given in the previous subsection. 178. 54 Bcast:19. I think the 1st one creates the table and the 2nd adds a line to it, so the reverse order shouldn't work. 255. rak weqic hwhyol arzsqze hzas ima tzglq tlibb laya plylv