CCIE Pursuit Blog

July 17, 2007

show ip route [network] [network mask] longer-prefixes

Filed under: Cool Commands,IOS — cciepursuit @ 11:46 am

Here’s a strange variation of the “show ip route” command that I stumbled across the other day: “show ip route [network] [network mask] longer-prefixes”.  The Cisco documentation is pretty brief:

(Optional) Specifies that only routes matching the ip-address and mask pair should be displayed.

I’m not sure how this is different than the “show ip route [network] [network mask]” command.  Here’s the output that I got when playing with this command:

The 10.2.0.0/16 route is in the routing table (advertised in via RIP).  If I try to do a “show ip route” on the /8 network, I get the following:
r1#sh ip route 10.2.0.0 255.0.0.0
% Subnet not in table

Here’s the output that I get with the “longer-prefixes” option:
r1#sh ip route 10.2.0.0 255.0.0.0 longer-prefixes
—some output truncated—

Gateway of last resort is not set

     10.0.0.0/16 is subnetted, 2 subnets
R       10.2.0.0 [120/1] via 12.0.0.2, 00:00:06, Serial0/0
C       10.1.0.0 is directly connected, FastEthernet0/0

The output makes sense if the “longer-prefixes” option is meant to display all 10.2.0.0 routes with prefixes of 8 or longer (/8 – /32).  The Cisco documentation looks like it is referring to the “show ip route [network] [network mask]” rather than the same command with the “longer-prefixes” option.

Well…it looks like I misinterpreted what this command does.  If you look a little further into the documentation, you’ll find an explanation of the “longer-prefixes” option as well as an example:

The following is sample output using the longer-prefixes keyword. When the longer-prefixes keyword is included, the address and mask pair becomes the prefix, and any address that matches that prefix is displayed. Therefore, multiple addresses are displayed.

In the following example, the logical AND operation is performed on the source address 10.0.0.0 and the mask 10.0.0.0, resulting in 10.0.0.0. Each destination in the routing table is also logically ANDed with the mask and compared to that result of 10.0.0.0. Any destinations that fall into that range are displayed in the output.

Router# show ip route 10.0.0.0 10.0.0.0 longer-prefixes

—some output truncated—

Gateway of last resort is not set

S 10.134.0.0 is directly connected, Ethernet0
S 10.10.0.0 is directly connected, Ethernet0
S 10.129.0.0 is directly connected, Ethernet0
S 10.128.0.0 is directly connected, Ethernet0
S 10.49.246.0 is directly connected, Ethernet0
S 10.160.97.0 is directly connected, Ethernet0
S 10.153.88.0 is directly connected, Ethernet0

In my first example “sh ip route 10.2.0.0 255.0.0.0″, the result of the logical AND would be 10:

00001010 <- 10
11111111 <- 255
________ <-logical AND
00001010 <- 10

So it makes sense that all of the 10.x.x.x networks were shown.


Cisco Documentation:show ip route

About these ads

Leave a Comment »

No comments yet.

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

The Rubric Theme. Create a free website or blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.

Join 113 other followers

%d bloggers like this: