Per Interface Gateway Routing
I have the following network configuration on Debian Etch:
I need to be able to force all data received/transmitted from eth1 (192.168.84.22) to go via 192.168.84.253 based on some port forwarding rules in the .253 router.
I tried adding "gateway 192.168.84.253" under eth1 but traffic still tries to go out via the default gateway .254. I also tried some "ip route" options but they do not work either.
I assumed that this woud be fairly simple to achieve but Googling has not provided me with a definitive answer.
you need to set up some rt_tables and use iproute2
Take a look at http://lartc.org
Essentially you'll end up setting a default route for each table and then add a rule saying anything from 192.168.84.22 goes out the table that has 192.168.84.253 as its gateway
add tables to /etc/iproute2/rt_tables
add default routes
ip route add default via 192.168.84.254 table out20
ip route add default via 192.168.84.253 table out22
then add some rules
ip rule add from 192.168.84.20 table out20
ip rule add from 192.168.84.22 table out22
Now anything that originates form 192.168.84.22 will use 192.168.84.253 as its gateway
I copied exactly what you posted and it's working perfectly. Thanks!
Thanks for the link also. I came across it whilst searching but was getting a bit confused. You have cleared it up though.
|All times are GMT -5. The time now is 08:58 AM.|