LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
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 05-24-2010, 04:09 AM   #1
ajmcello
LQ Newbie
 
Registered: May 2010
Posts: 8

Rep: Reputation: 0
Two default gateways.


I have two network cards, eth0, and eth1. Each interface has an IP address with the option of having a default gateway, but at present only eth0's gateway is set up as the default route.

I have applications that can launch using -iface ethX. They work fine when using eth0, but not eth1, unless I remove my default route for eth0 and add eth1 as the default route or add a static route to that interface.

My question is this: How can I make it so that I can have two default routes, with eth1's default route only being used when packets flow in or out of eth1?

Is this possible?

Thanks in advance!
 
Old 05-24-2010, 04:24 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
If configuring from the command line then you can specify a default route for each interface using route add and specifying the interface with dev. If you want to configure from the GUI then please tell us which distro and desktop you are using.
 
Old 05-24-2010, 11:56 AM   #3
anomie
Senior Member
 
Registered: Nov 2004
Location: Texas
Distribution: RHEL, Scientific Linux, Debian, Fedora
Posts: 3,935
Blog Entries: 5

Rep: Reputation: Disabled
Also, read here: http://www.linuxjournal.com/article/7291

On RHEL4 and RHEL5 systems, this is the way to make sure routing for multi-homed systems is working as you'd expect.
 
Old 05-25-2010, 03:07 PM   #4
jvaldivia
Member
 
Registered: Sep 2007
Distribution: Debian Lenny
Posts: 61
Blog Entries: 2

Rep: Reputation: 19
To have 2 default gateways you have to configure iproute version 2, I wrote a how to here. http://soad1982.blogspot.com/2010/02...-on-linux.html
 
Old 06-01-2010, 09:36 AM   #5
ajmcello
LQ Newbie
 
Registered: May 2010
Posts: 8

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by jvaldivia View Post
To have 2 default gateways you have to configure iproute version 2, I wrote a how to here. http://soad1982.blogspot.com/2010/02...-on-linux.html
This got me really close! Here's the problem I'm having now..

eth0 is 192.168.1.15 which is also part of my default network, with 192.168.1.1 being my default route. this works fine.

ppp0 is an outside provider, that sometimes gives me the same IP as what I have on eth0. sometimes I get a different IP for ppp0, but is still within the same subnet as eth0.

when adding the following rule, to try and make any packets seen from 192.168.1.15 on dev ppp0, it still routes out through eth0:

ip rule add from 192.168.1.15 dev ppp0 table ppp0 pref 100
ip route add default via 192.168.1.15 dev ppp0 table ppp0

what am I doing wrong that it won't let me route packets out through dev ppp0 with the same IP as eth0 or an IP within the same subnet as eth0? I suppose the easy answer is to change my default network on eth0, which does work with the following rules, as long as it doesn't match what is on eth0:

ip rule add from 192.168.1.15 table ppp0 pref 100
ip route add default via 192.168.1.15 dev ppp0 table ppp0

...but as soon as I add:

ip rule add from 192.168.1.15 dev ppp0 table ppp0 pref 100
ip route add default via 192.168.1.15 dev ppp0 table ppp0

it will not route properly. I've tried using 192.168.1.15/32, 192.168.1.0/24 but not having any luck.

Thanks in advance.
 
  


Reply



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
iptables: marking packets for routing to two default gateways obaidmushtaq Linux - Networking 2 01-19-2010 09:01 AM
multiple default gateways jireson Linux - Networking 3 02-04-2006 01:24 AM
rc.inet1, routes, default gateways Woodsman Slackware 1 01-06-2006 12:41 AM
how are multiple default gateways handled? eantoranz Linux - Networking 9 06-01-2005 02:09 PM
3 network cards and 2 default gateways Oderus Linux - Networking 2 10-20-2004 03:04 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 11:33 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration