Does the order of entries in the routing table matter?
--------------------------------------------------
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Question
01:11 Accepted answer (Score 36)
01:51 Answer 2 (Score 7)
02:28 Thank you
--
Full question
https://superuser.com/questions/622750/d...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#router #ip #routing #arp
#avk47
Become or hire the top 3% of the developers on Toptal https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Unforgiving Himalayas Looping
--
Chapters
00:00 Question
01:11 Accepted answer (Score 36)
01:51 Answer 2 (Score 7)
02:28 Thank you
--
Full question
https://superuser.com/questions/622750/d...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#router #ip #routing #arp
#avk47
ACCEPTED ANSWER
Score 36
The order in the table doesn't matter; routes with a longer prefix always take priority. If you stop clinging to netmasks and consider the prefix lengths instead (which ip route
shows), you have 123.x.x.128/27
and 123.x.x.151/32
, and the latter – more specific – route will take priority over the former (more generic one).
ANSWER 2
Score 7
Order only matters if you have duplicate routes. Don't do that.
For example, if two interfaces have the same destination, netmask, and gateway of 0.0.0.0, the first one will grab all the traffic for that network.
What's more, I've found some systems will randomly reorder on boot which one comes first. If only one works, or only one has a router gateway set, this can result in losing access to that network on reboot.