LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices

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

Rep: Reputation: 0
Per Interface Gateway Routing


I have the following network configuration on Debian Etch:

Code:
auto lo
iface lo inet loopback

auto eth0
iface eth0 inet static
        address         192.168.84.20
        netmask         255.255.255.0
        gateway         192.168.84.254

auto eth1
iface eth1 inet static
        address         192.168.84.22
        netmask         255.255.255.0
I also have 2 Gateways on the network that go to the internet on 192.168.84.254 and 192.168.84.253.

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.
 
Old 11-17-2008, 09:21 PM   #2
estabroo
Senior Member
 
Registered: Jun 2008
Distribution: debian, ubuntu, sidux
Posts: 1,095
Blog Entries: 2

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

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

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

Last edited by estabroo; 11-17-2008 at 09:23 PM. Reason: fixed url
 
Old 11-18-2008, 12:12 AM   #3
Jelloir
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.
 
  


Reply


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 11:30 AM
Routing or Gateway Problem Peter_APIIT Linux - Networking 24 01-26-2008 06:37 AM
vpn routing without the gateway karen.pertierra Linux - Networking 1 03-18-2007 07:39 AM
Linux Routing and Gateway GavSim Linux - Networking 1 02-08-2006 03:08 PM
ip + interface + gateway alaios Debian 3 11-12-2004 05:35 PM


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

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