Download your favorite Linux distribution at LQ ISO.
Go Back > Forums > Linux Forums > Linux - Networking
User Name
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.


  Search this Thread
Old 11-17-2008, 07:23 PM   #1
LQ Newbie
Registered: Nov 2008
Posts: 5

Rep: Reputation: 0
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.
Old 11-17-2008, 08:21 PM   #2
Senior Member
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,125
Blog Entries: 2

Rep: Reputation: 124Reputation: 124
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

Last edited by estabroo; 11-17-2008 at 08:23 PM. Reason: fixed url
Old 11-17-2008, 11:12 PM   #3
LQ Newbie
Registered: Nov 2008
Posts: 5

Original Poster
Rep: Reputation: 0
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.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Routing through a gateway Tom Douglas Linux - Networking 7 10-25-2008 10:30 AM
Routing or Gateway Problem Peter_APIIT Linux - Networking 24 01-26-2008 05:37 AM
vpn routing without the gateway karen.pertierra Linux - Networking 1 03-18-2007 06:39 AM
Linux Routing and Gateway GavSim Linux - Networking 1 02-08-2006 02:08 PM
ip + interface + gateway alaios Debian 3 11-12-2004 04:35 PM > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 02:35 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration