Cisco Support Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Community Member

Sorting the Routing Table

Using the "show ip route" command. First, how is the output actually sorted? Also is there any way to sort the table so the host or network routes are in order from 1.1.1.1 to 255.255.255.255 for example? Yes you could drop this to excel and then sort from A to Z but you would think there is a way to do this in IOS. Specifically 12.4(25)T2.

Thanks

7 REPLIES
Cisco Employee

Re: Sorting the Routing Table

Hi,

The ouput of the show ip route reflects the internal tree used to store the prefixes.

In 12.2SR for 7600 the routes for each "classfull entry" are sorted but it's not consistent across all IOS releases.

Gateway of last resort is not set

      3.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

S        3.0.0.0/8 [1/0] via 172.16.33.1, Ethernet1/0.15

B        3.1.1.1/32 [20/0] via 172.16.33.1, 1w0d

      10.0.0.0/32 is subnetted, 8 subnets

O        10.1.1.1 [110/31] via 192.168.2.9, 1w0d, Ethernet0/0

C        10.1.1.3 is directly connected, Loopback0

O        10.1.1.4 [110/31] via 192.168.2.9, 1w0d, Ethernet0/0

C        10.3.3.3 is directly connected, Loopback3

O        10.10.1.1 [110/21] via 192.168.2.9, 1w0d, Ethernet0/0

O        10.10.1.2 [110/21] via 192.168.2.9, 1w0d, Ethernet0/0

O        10.10.1.3 [110/11] via 192.168.2.9, 1w0d, Ethernet0/0

O        10.10.1.4 [110/21] via 192.168.2.9, 1w0d, Ethernet0/0

Thanks

Laurent.

Re: Sorting the Routing Table

Hi Laurent,

I once tried a "show ip route | include x.x.x.x" on a 7206VXR with full routing and the poor router almost kissed me goodbye! (Don't try this at work! ). Although the previous incident I mentioned is not entirely the same procedure as IOS printing the routing table, may I ask if this unsorted output is done specifically for performance reasons?

Kind Regards,

Maria

Cisco Employee

Re: Sorting the Routing Table

Hi Maria,

The way the prefixes are stored in the router is based on a tree. I don't know all the details but the show ip route reflects how the tree is build.

Yes, we can say the tree is build in a way to improve the lookup performance even if now it's cef who is doing it. CEF uses a MTree to store all the prefixes.

HTH

Laurent.

Re: Sorting the Routing Table

Hi Laurent,

Thanks for your reply. Sorry I didn't phrase my question very well in the first place. I am not asking about the details of tree (not because I am not interested, but I usually forget complex details and always have to look them up anyway :-). Since the internal representation of the routing table is different than a perfectly sorted list, could the sorted printing of the routing table cause delay in the "sh ip route" output or high CPU usage on the router or inconsistencies in the output or anything like that? I mean why the developers have chosen not to print it sorted in the first place? Or is there no issue and we could expect at some point in the future to see it sorted?

Thanks in advance,

Maria

Cisco Employee

Re: Sorting the Routing Table

Hi Maria,

I don't know what the DE had in mind back then when they coded this command which is pretty old now but I assume they chose the easiest way meaning they print the routes the same way they are stored.

As I said in my previous post, the behavior was improved a little bit in 12.2SR train.

I'm not expecting any changes on other train as our DE's have more critical bugs to fix ;-)

Thanks

Laurent.

Re: Sorting the Routing Table

Hi Laurent,

If your DE's manage to fix all the critical bugs, then I guess we could live with the routing table being printed even in reverse chronological order! I personally never minded about the order, because I find the "sh ip rou " a more useful troubleshooting command.

Kind Regards,

Maria

Super Bronze

Re: Sorting the Routing Table

Disclaimer

The Author of this posting offers the information contained within this posting without consideration and with the reader's understanding that there's no implied or expressed suitability or fitness for any purpose. Information provided is for informational purposes only and should not be construed as rendering professional advice of any kind. Usage of this posting's information is solely at reader's own risk.

Liability Disclaimer

In no event shall Author be liable for any damages whatsoever (including, without limitation, damages for loss of use, data or profit) arising out of the use or inability to use the posting's information even if Author has been advised of the possibility of such damage.

Posting

Also is there any way to sort the table so the host or network routes are in order from 1.1.1.1 to 255.255.255.255 for example?

Not the exactly same information, but have you tried a show ip cef (if CEF is enabled)?

2314
Views
15
Helpful
7
Replies
CreatePlease to create content