Skip to contentSkip to conversation

route sorting

DISCUSSION Mr Dash Four 5 participants 6 messages Oct 17, 2011

lore
Share & tools
lore
#0 lore raw

When I execute "route" to display my routing table all entries are sorted by ip address (when -n is specified). This seems to be a bit different from previous kernel versions (I am using 3.0.6) - 2.6.38 for example - where the routing table used to show the most specific netmask first (at the top), which is what I really wanted as it was very easy to judge how a particular ip address is going to be routed. When I execute "route" now I can't get it to show the routing table the way I want and the way it was done in previous kernel versions. Any suggestions?

#1 lore raw

W dniu 17.10.2011 14:22, Mr Dash Four pisze:

Quoted 6 lines

When I execute "route" to display my routing table all entries are sorted by ip address (when -n is specified). This seems to be a bit different from previous kernel versions (I am using 3.0.6) - 2.6.38 for example - where the routing table used to show the most specific netmask first (at the top), which is what I really wanted as it was very easy to judge how a particular ip address is going to be routed. When I execute

Hello,
i can't help you with "sorting problem" but i can see the real problem is "i want to know which path will be used for given address ip". I suggest to use iproute2, e.g.: ip r g <address_ip> This is output:

# ip r g 4.5.6.7
4.5.6.7 via 88.198.102.193 dev eth0  src 88.198.102.195
    cache

Regards

#2 lore raw
Quoted 7 lines · Marcin MirosÅ‚aw

Hello,
i can't help you with "sorting problem" but i can see the real problem is "i want to know which path will be used for given address ip". I suggest to use iproute2, e.g.: ip r g <address_ip>
This is output:

# ip r g 4.5.6.7
4.5.6.7 via 88.198.102.193 dev eth0  src 88.198.102.195

To clarify, that's "ip route get <ip>". You can use shortcuts, but for examples for beginners that may not be wise.

Another reason to use iproute2 ("ip") is that "route" is deprecated, and cannot display all of the things iproute2 now reveals. Such as multiple routes, metrics, or sources (such as from zebra/quagga). Finally, "ip rule" helps you to see policy routes like source-based routing. "route" cannot do any of that.

Regards,
Tyler

Signature · 3 lines
"Never underestimate the bandwidth of a station wagon full of tapes
hurtling down the highway.
   -- Andrew S. Tanenbaum
#3 lore raw
Quoted 10 lines
Quoted 9 lines

Hello,
i can't help you with "sorting problem" but i can see the real problem is "i want to know which path will be used for given address ip". I suggest to use iproute2, e.g.: ip r g <address_ip>
This is output:

# ip r g 4.5.6.7
4.5.6.7 via 88.198.102.193 dev eth0  src 88.198.102.195
Quoted 3 lines

To clarify, that's "ip route get <ip>". You can use shortcuts, but for examples for beginners that may not be wise.

Yeah, I figured that one out. I use iproute2 to build my routing table, but never thought of using it to trace route paths as the "old" route was more convenient - to me anyway.

Quoted 6 lines

Another reason to use iproute2 ("ip") is that "route" is deprecated, and cannot display all of the things iproute2 now reveals. Such as multiple routes, metrics, or sources (such as from zebra/quagga). Finally, "ip rule" helps you to see policy routes like source-based routing. "route" cannot do any of that.

Yeah, that helped - thank you both! I think I also found a little discrepancy while executing "ip rule list <number>" (wrong syntax, obviously) - it shows me "'ip rule show' does not take any arguments." error message. Should that be ""ip rule list" does not take any arguments." instead?

I am still curious though why the sorting order in the old "route" has changed from one kernel version to the next?

#4 lore raw
Quoted 5 lines · Mr Dash Four

Yeah, that helped - thank you both! I think I also found a little discrepancy while executing "ip rule list <number>" (wrong syntax, obviously) - it shows me "'ip rule show' does not take any arguments." error message. Should that be ""ip rule list" does not take any arguments." instead?

show and list are equal, and FWIW, the number you see is not a rule number, but a priority.

Quoted 2 lines

I am still curious though why the sorting order in the old "route" has changed from one kernel version to the next?

Possibly because the kernel changed its way, and ye olde broken net-tools does not sort it on its own. (Similar to how getdents/readdir is not required to return entries in sorted fashion)

#5 lore raw
In reply to Mr Dash Four

From: Mr Dash Four <[email protected]>
Date: Mon, 17 Oct 2011 16:37:59 +0100

Quoted 2 lines

I am still curious though why the sorting order in the old "route" has changed from one kernel version to the next?

Because the underlying datastructure used to hold the table has changed.