1

I ran across two entries in a linux routing table that both have the same destination, but have different gateways. How would this traffic be routed? I've been searching around online for additional information, as it seems like this type of setup would be common, although I am having a difficult time tracking down any information on this (might be wording it incorrectly). I am assuming that the route with a gateway of 12.12.12.12 would automatically be used, or would traffic be load balanced over the two routes instead?

11.11.11.11    12.12.12.12    255.255.248.0   UG        0 0          0 eth1
11.11.11.11    0.0.0.0         255.255.248.0   U         0 0          0 eth1

Thank you

lacrosse1991
  • 1,407
  • 5
  • 19
  • 24
  • 1
    linux uses "longest prefix match", which means the most specific route is chosen. In your case the 12.12.12.12 GW is more specific than the default GW (0.0.0.0), so it would always be used. See additional info here on discussion of if you applied priority/metrics to the gateways: http://serverfault.com/questions/648276/routing-selection-specificity-vs-metric – jlehtinen Mar 18 '15 at 14:52
  • @jlehtinen sounds good, thanks. With the longest prefix, wouldn't that just applying to the destination? (since the listed mask is for that) – lacrosse1991 Mar 18 '15 at 15:04
  • In your example, traffic for 11.11.11.11/21 would be routed through 12.12.12.12. Other traffic would be routed according to whatever other routes are defined. – jlehtinen Mar 18 '15 at 15:13

1 Answers1

2

To find out how it works try:

ip route get ADDRESS [ from ADDRESS iif STRING ]
                     [ oif STRING ] [ tos TOS ]
                     [ mark NUMBER ]

it will tell you where/how packet with such parameters gets routed

Fox
  • 3,887
  • 16
  • 23