I have 2 connections: wlan0 (gw: 192.168.1.1) and eth0 (gw: 192.168.2.1).
My default connection is wlan0, but I wanted some websites load through my eth0, so I set up routing for those websites/IPs like this:
route add -net 18.104.22.168/21 gw 192.168.2.1 dev eth0
This works, however is not permanent (disappears after reboot). I tried to put this code in
/etc/network/interfaces like this:
up route add -net 22.214.171.124/21 gw 192.168.2.1 dev eth0
but when I restart Ubuntu, it starts without networking (it crashes). I also put these lines into that file:
auto eth0 address 192.168.2.125 gateway 192.168.2.1 netmask 255.255.255.0
but still system boots without networking.
Currently I have put
route command into
/etc/rc.local, it works, but it is not permanent, because when I restart/re-connect my eth0 (for some reason), routing disappears.
I have long list of IPs to route.
My router, which I connected eth0 is set to DHCP.
I tried to connect eth0 both static and DHCP way.
Thanks for you help!