Problem: Direct all traffic except for specific subnet (10.168.201.0/24) to eth0 and all remaining traffic to eth1.
Code:
$ ifconfig
eth0 Link encap:Ethernet HWaddr b8:ac:6f:42:22:a4
inet addr:10.168.201.93 Bcast:10.168.201.255 Mask:255.255.255.0
inet6 addr: fe80::baac:6fff:fe42:22a4/64 Scope:Link
eth1 Link encap:Ethernet HWaddr 64:70:02:09:32:f6
inet addr:10.0.1.49 Bcast:10.0.1.255 Mask:255.255.255.0
inet6 addr: 2601:1:b300:4:6670:2ff:fe09:32f6/64 Scope:Global
inet6 addr: fe80::6670:2ff:fe09:32f6/64 Scope:Link
Code:
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
10.168.201.0 0.0.0.0 255.255.255.0 U 1 0 0 eth0
10.0.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth1
169.254.0.0 0.0.0.0 255.255.0.0 U 1000 0 0 eth0
0.0.0.0 10.168.201.254 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 10.0.1.1 0.0.0.0 UG 100 0 0 eth1
I have the following code which should direct all traffic to return to the same port it is from so actions on the internet should not have an issue. Please correct me if I am wrong.
Code:
ip route add 10.168.201.0/24 dev eth0 src 10.168.201.93 table local1
ip route add default via 10.168.201.254 table local1
ip route add 10.0.1.0/24 dev eth1 src 10.0.1.49 table inet
ip route add default via 10.0.1.1 table inet
ip route add 10.168.201.0/24 dev eth0 src 10.168.201.93
ip route add 10.0.1.0/24 dev eth1 src 10.0.1.49
ip route add default via 10.0.1.1
ip rule add from 10.168.201.93 table local1
ip rule add from 10.0.1.49 table inet
Bookmarks