View previous topic :: View next topic |
Author |
Message |
numerodix l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/50ca19a23ded101ddd1e4.jpg)
Joined: 18 Jul 2002 Posts: 743 Location: nl.eu
|
Posted: Thu Jun 11, 2009 6:08 pm Post subject: How does the kernel decide which route (of 2) to use? |
|
|
Suppose you are connected to two networks on two interfaces. The networks are configured identically.
You get something like this:
Code: | $ /sbin/route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
192.168.1.0 0.0.0.0 255.255.255.0 U 0 0 0 eth0
192.168.0.0 0.0.0.0 255.255.255.0 U 2000 0 0 wlan0
127.0.0.0 0.0.0.0 255.0.0.0 U 0 0 0 lo
0.0.0.0 192.168.1.1 0.0.0.0 UG 0 0 0 eth0
0.0.0.0 192.168.0.1 0.0.0.0 UG 2000 0 0 wlan0 |
So now a packet destined outside 192.168.{0,1} must travel either via 192.168.1.1 or 192.168.0.1, but the choice is arbitrary. It might turn out that one of them is a dead end, that past the gateway there's a network partition. Maybe that's why you're on two networks to begin with. So how does the kernel decide which gateway to use? _________________ undvd - ripping dvds should be as simple as unzip |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Chaosite Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/1061141068427f6466ca728.jpg)
Joined: 13 Dec 2003 Posts: 540 Location: Right over here.
|
Posted: Thu Jun 11, 2009 6:41 pm Post subject: |
|
|
When doing complex things with routing, you should use the iproute2 tools.
$ /sbin/ip route
10.0.0.0/24 dev eth2 proto kernel scope link src 10.0.0.127
127.0.0.0/8 dev lo scope link
default via 10.0.0.254 dev eth2
And the, suprising enough, answer is: the kernel uses the first route which is available to it. You can do more complex stuff than that, if you desire, though - there are several advanced routing HOWTOs on the net. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Monkeh Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/158504026146c5220a4feda.png)
Joined: 06 Aug 2005 Posts: 1656 Location: England
|
Posted: Thu Jun 11, 2009 6:46 pm Post subject: |
|
|
Uh, that's what the metric is for. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Chaosite Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/1061141068427f6466ca728.jpg)
Joined: 13 Dec 2003 Posts: 540 Location: Right over here.
|
Posted: Thu Jun 11, 2009 6:48 pm Post subject: |
|
|
Monkeh wrote: | Uh, that's what the metric is for. |
... Really? What is the metric for, anyway?
manpage isn't very helpful with "set the metric field in the routing table (used by routing daemons) to M.". |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
numerodix l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/50ca19a23ded101ddd1e4.jpg)
Joined: 18 Jul 2002 Posts: 743 Location: nl.eu
|
Posted: Thu Jun 11, 2009 7:05 pm Post subject: |
|
|
manpage also says:
Code: | Metric The ’distance’ to the target (usually counted in hops). It is not used
by recent kernels, but may be needed by routing daemons. |
@Chaosite
What makes iproute2 more worthwhile? Am I not getting the same info from "ip route" as I am from "route"? _________________ undvd - ripping dvds should be as simple as unzip |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
jdmulloy Tux's lil' helper
![Tux's lil' helper Tux's lil' helper](/images/ranks/rank_rect_1.gif)
![](images/avatars/114454834747cf6999b0ef0.jpg)
Joined: 24 Dec 2004 Posts: 139 Location: Massachusetts, USA
|
Posted: Thu Jun 11, 2009 8:40 pm Post subject: |
|
|
So I'm thinking the question is basically, if both private networks have a gateway to say the public internet and one of them is down is the kernel smart enough to work around it? _________________ Joe Mulloy | http://twitter.com/jdmulloy | Ron Paul in 2012! | 5-1-07 | Unban Playfool | Fire your "Too big to fail" bank http://moveyourmoney.info |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
aidanjt Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/7201124414f1a4ed204f8d.jpg)
Joined: 20 Feb 2005 Posts: 1118 Location: Rep. of Ireland
|
Posted: Thu Jun 11, 2009 8:46 pm Post subject: |
|
|
It'll go by shortest (or only) route first. The kernel maintains different kinds of tables on the network state and make routing decisions based upon that. _________________
juniper wrote: | you experience political reality dilation when travelling at american political speeds. it's in einstein's formulas. it's not their fault. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
numerodix l33t
![l33t l33t](/images/ranks/rank_rect_4.gif)
![](images/avatars/50ca19a23ded101ddd1e4.jpg)
Joined: 18 Jul 2002 Posts: 743 Location: nl.eu
|
Posted: Thu Jun 11, 2009 9:12 pm Post subject: |
|
|
AidanJT wrote: | It'll go by shortest (or only) route first. The kernel maintains different kinds of tables on the network state and make routing decisions based upon that. |
But before any traffic has been sent, it doesn't have any cached information. So what happens? Does it try one first, then the other if the first doesn't work? _________________ undvd - ripping dvds should be as simple as unzip |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
aidanjt Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/7201124414f1a4ed204f8d.jpg)
Joined: 20 Feb 2005 Posts: 1118 Location: Rep. of Ireland
|
Posted: Thu Jun 11, 2009 9:21 pm Post subject: |
|
|
numerodix wrote: | But before any traffic has been sent, it doesn't have any cached information. So what happens? Does it try one first, then the other if the first doesn't work? |
Normally it sends out a RIP request first to update it's own tables, if it can't do that, then it falls back on the send'n'pray method and maintains routing tables by its sweet lonesome. But normally the route for a given network only has one interface path, unless we're talking about backbone routing of course. _________________
juniper wrote: | you experience political reality dilation when travelling at american political speeds. it's in einstein's formulas. it's not their fault. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
bunder Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
Joined: 10 Apr 2004 Posts: 5947
|
Posted: Thu Jun 11, 2009 9:36 pm Post subject: |
|
|
shouldn't there be only one default gateway? ![Confused :?](images/smiles/icon_confused.gif) _________________
Neddyseagoon wrote: | The problem with leaving is that you can only do it once and it reduces your influence. |
banned from #gentoo since sept 2017 |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
aidanjt Veteran
![Veteran Veteran](/images/ranks/rank_rect_5_vet.gif)
![](images/avatars/7201124414f1a4ed204f8d.jpg)
Joined: 20 Feb 2005 Posts: 1118 Location: Rep. of Ireland
|
Posted: Thu Jun 11, 2009 11:03 pm Post subject: |
|
|
bunder wrote: | shouldn't there be only one default gateway? ![Confused :?](images/smiles/icon_confused.gif) |
Nope, you can have multiple routes to the tubes. _________________
juniper wrote: | you experience political reality dilation when travelling at american political speeds. it's in einstein's formulas. it's not their fault. |
|
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
Chaosite Guru
![Guru Guru](/images/ranks/rank_rect_3.gif)
![](images/avatars/1061141068427f6466ca728.jpg)
Joined: 13 Dec 2003 Posts: 540 Location: Right over here.
|
Posted: Fri Jun 12, 2009 5:07 am Post subject: |
|
|
numerodix wrote: | @Chaosite
What makes iproute2 more worthwhile? Am I not getting the same info from "ip route" as I am from "route"? |
http://lartc.org/howto/lartc.iproute2.html
Here's how to add a multipath route (google this term) using iproute2:
Code: | ip route add default nexthop via 10.0.0.1 dev eth0 nexthop via 10.1.0.1 dev wlan0 |
You can add weight to it too. Note that if your failures cause the interface to go down, you can just have 2 default routes, and once the interface goes down one of them will disappear. It's up to you to put it back once the interface goes back again. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
desultory Bodhisattva
![Bodhisattva Bodhisattva](/images/ranks/rank-bodhisattva.gif)
![](images/avatars/15563850365c4d454383627.gif)
Joined: 04 Nov 2005 Posts: 9410
|
Posted: Fri Jun 12, 2009 7:52 am Post subject: |
|
|
Moved from Off the Wall to Networking & Security. |
|
Back to top |
|
![](templates/gentoo/images/spacer.gif) |
|