-   Linux - Networking (
-   -   Per Interface Gateway Routing (

Jelloir 11-17-2008 07:23 PM

Per Interface Gateway Routing
I have the following network configuration on Debian Etch:


auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static

auto eth1
iface eth1 inet static

I also have 2 Gateways on the network that go to the internet on and

I need to be able to force all data received/transmitted from eth1 ( to go via based on some port forwarding rules in the .253 router.

I tried adding "gateway" 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.

estabroo 11-17-2008 08:21 PM

you need to set up some rt_tables and use iproute2

Take a look at

Essentially you'll end up setting a default route for each table and then add a rule saying anything from goes out the table that has as its gateway

for example:
add tables to /etc/iproute2/rt_tables
20 out20
22 out22

add default routes
ip route add default via table out20
ip route add default via table out22

then add some rules
ip rule add from table out20
ip rule add from table out22

Now anything that originates form will use as its gateway

Jelloir 11-17-2008 11:12 PM

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.

Much appreciated.

All times are GMT -5. The time now is 08:25 PM.