Show All Routes Within a Particular Block

Posted on in Networking

Train Track Switching YardI've got a Class C (/24, subnet of 256 IPs) that I assign glue addresses for point-to-point links out of. Although all these little /30 subnets are in the same location, they are not guaranteed to be on the same router. So, the question is, how can I see which /30s I've assigned while working on the router? In other words, how can I see these blocks without referring to an outside IP management system?

The answer lies in the show ip route command. Most network administrators are used to using this command to see what routes are in their routing table (ie, show ip route), or to check on the route to a specific IP address (ie, show ip route <ip address>). But many network administrators would be surprised to learn that there is additional functionality in this command. Specifically, the ability to specify a subnet mask and request longer prefixes. Both of these are crucial to solving our problem.

The first thing you might try is to specify the Class C and see if the router dumps all routes within that Class C. Unfortunately, show ip route <ip address> only shows the /30 at the beginning of the block. Adding a subnet mask (show ip route <ip address> <subnet mask>) yields the dreaded % Subnet not in table response. Requesting longer prefixes returns the results desired (show ip route <ip address> <subnet mask> longer-prefixes).

Let's see an example (obviously, I've doctored this up to protect the networks anonymity).

SLAP>show ip route longer-prefixes
Codes: C - connected, S - static, R - RIP, M - mobile, B - BGP
       D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
       N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
       E1 - OSPF external type 1, E2 - OSPF external type 2
       i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2
       ia - IS-IS inter area, * - candidate default, U - per-user static route
       o - ODR, P - periodic downloaded static route

Gateway of last resort is not set is variably subnetted, 3434 subnets, 19 masks
i L1 [15/14] via, GigabitEthernet5/0/0
C is directly connected, POS1/0/0
i L1 [15/37] via, GigabitEthernet5/0/0
i L1 [15/24] via, POS1/0/0
i L1 [15/24] via, POS1/0/0
C is directly connected, Serial0/0/0/2:0
C is directly connected, Serial0/0/0/1:0
i L1 [15/24] via, POS1/0/0
i L1 [15/24] via, POS1/0/0
i L1 [15/34] via, POS1/0/0
i L1 [15/8] via, POS1/0/0


Although it's not an Earth shattering tip, it comes in handy more frequently than you might imagine.

Recommended Reading:

Cisco Routers for the Desperate: Router Management, The Easy Way\ [Cisco Router Troubleshooting Handbook
Cisco Routers for the Desperate:\ Cisco Router Troubleshooting Handbook]( Router Management, The Easy Way

My Bookshelf

Reading Now

Other Stuff