Linux route command. Two gatways on the same subnet range

linuxroutesubnet

I have a Linux box with two interfaces.
eth0 has ip 192.168.71.82/255.255.252.0
eth1 has ip 192.168.4.2/255.255.255.0
I need all traffic for subnets 192.168.4.0/24 192.168.3.0/24 192.168.2.0/24 to go through eth1 and all the rest to go through eth0.
Which is the best way to do this?
route command?
Cheers for the help.

Best Answer

Just set routes to your desired Networks over eth1:

route add -net 192.168.4.0 netmask 255.255.255.0 dev eth1
route add -net .........

And then set your default gateway to whatever you need:

route add default dev eth0

(Nevertheless a route using an interface looks a bit strange to me - usually you should address the gateways using the correct router(s):

route add -net 192.168.3.0 netmask 255.255.255.0 gw <your routers IP>