Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have some entries in a routing table that were created using longest prefix matching, and I have to use those entries to determine the a.b.c.d/x notation (CIDR).

This is an example entry:

11001000 00010111 00010.

That was calculated from the range

11001000 00010111 00010000 00000000 through 11001000 00010111 00010111 11111111.

I know the range is from IP addresses to, but getting the /x for the subnet # doesn't make sense to me. Anyone know how to properly go about calculating it?

share|improve this question
how and where did you get the binary representation? – Serge Oct 3 '12 at 2:43
I first had a table of destination address ranges like the second set of binary numbers you see above (with the "through"), then I had to make a forwarding table using the longest matching prefix needed to forward packets to a link interface. That's why it isn't a perfect set of octets. – mighty_squash Oct 3 '12 at 2:48
ok. so your problem is only to determine the /x part, right? – Serge Oct 3 '12 at 2:50
Yeah, I just don't know how to calculate that although everywhere I look assumes you know how to do it. – mighty_squash Oct 3 '12 at 2:53
up vote 2 down vote accepted

As a subnet number is not of your interest then your task is simple. You count the digits in your entry. That's it. So, with your sample we have:

11001000 00010111 00010


The /x is /21

share|improve this answer
I had a feeling this was the approach, it just didn't seem right because it was too easy. – mighty_squash Oct 3 '12 at 3:06
yes, that simple ) – Serge Oct 3 '12 at 3:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.