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 172.16.9.0 255.255.255.0 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

     172.16.0.0/16 is variably subnetted, 3434 subnets, 19 masks
i L1    172.16.9.32/30 [15/14] via 172.16.9.83, GigabitEthernet5/0/0
C       172.16.9.40/30 is directly connected, POS1/0/0
i L1    172.16.9.48/30 [15/37] via 172.16.9.83, GigabitEthernet5/0/0
i L1    172.16.9.52/30 [15/24] via 172.16.9.42, POS1/0/0
i L1    172.16.9.64/30 [15/24] via 172.16.9.42, POS1/0/0
C       172.16.9.72/30 is directly connected, Serial0/0/0/2:0
C       172.16.9.76/30 is directly connected, Serial0/0/0/1:0
i L1    172.16.9.96/30 [15/24] via 172.16.9.42, POS1/0/0
i L1    172.16.9.100/30 [15/24] via 172.16.9.42, POS1/0/0
i L1    172.16.9.104/30 [15/34] via 172.16.9.42, POS1/0/0
i L1    172.16.9.108/30 [15/8] via 172.16.9.42, POS1/0/0

</code>

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](https://www.amazon.com/gp/product/0764546473/?tag=slaptijack-20) Router Management, The Easy Way


Slaptijack's Koding Kraken