Webnet77 Christian web host


Hosting Packages


WebStarter $25.95 / 6 mo
WebBuilder $35.95 / 6 mo
WebMaster $49.95 / 6 mo
WebPro $199.00 / 6 mo
 

Christian
web hosting

Download the IP to Country Database here
 CIDR 101 FOR DUMMIES


CIDR stand for Classless Inter-Domain Routing. I will not go into the detail of Networks and hosts and network masks. What we are interested in here is only this:

  1. What is a CIDR?

  2. What does a CIDR number represent?

  3. How does one go about calculating one?

The Fundamentals

An IPV4 address we are all familiar with looks like so XX.XX.XX.XX where XX is a number between 0 and 255. For example 127.0.0.0 or 10.0.0.1

Now, what if we wanted to express a range of IP addresses? How would we do that? We could do it like this:

10.0.0.0-10.0.0.255 which means all the IP numbers between 10.0.0.0 and 10.0.0.255 inclusive.

But there is a shorter way to do it. Like this:

10.0.0.0/24 or even 10.0.0/24

OK, here's the arithmetic:

an IP address is actually a binary number 32 bits long. To make it "more readable" we split the 32 bits into 4 groups of 8 bits like so

Example #1: 10.0.0.1

IP10001
8 Bit Blocks8 bits [24-31]8 bits [16-23]8 bits [08-15]8 bits [00-07]
Bit # 3130292827262524232221201918171615141312111009080706050403020100
Decimal 1286432 168421128643216842112864321684211286432168421
Binary00001010000000000000000000000 001

Example #2: 192.168.0.15

IP192168015
8 Bit Blocks8 bits [24-31]8 bits [16-23]8 bits [08-15]8 bits [00-07]
Bit # 3130292827262524232221201918171615141312111009080706050403020100
Decimal 128643216 8421128643216842112864321684211286432168421
Binary11 000001010100000000000 0000111 1

Example #3: 255.255.255.255 (all 1's)

IP255255255255
8 Bit Blocks8 bits [24-31]8 bits [16-23]8 bits [08-15]8 bits [00-07]
Bit # 3130292827262524232221201918171615141312111009080706050403020100
Decimal 1286432168421128643216842112864321684211286432168421
Binary11111111111 11111111111111111111 1

Do not read what follows if you don't get what was said above

 

What is a CIDR and what does it represent?

In short, a CIDR is a shorthand method for representing a range of IP addresses.

Here are some examples of CIDR Numbers:

  CIDR Representing IP
NUMBERS FROM
 .... TO
Notice these two
mean the same
127.0.0.0/24 127.0.0.0 127.0.0.255
127.0.0/24 127.0.0.0 127.0.0.255
Notice these two
also mean the same
32.0.0.0/8 32.0.0.0 32.255.255.255
32/8 32.0.0.0 32.255.255.255

How does 32/8 mean 32.0.0.0 to 32.255.255.255?

We are agreed that an IP number is made up of 32 bits in binary format right? (See Examples #1, #2, #3 above). What 32/8 or 32.0.0.0/8 means (they are synonymous) is this:

  • The first 8 bits will be used to indicate the starting IP number

  • The remaining 24 bits (32 -8) will be used to determine ending IP number. All of the 24 remaining bits can be either 1's or 0's which is the same as 2 to the power of 24 numbers in range.

Lets see what this looks like spelt out:

START
Start IP 32 0 0 0
8 Bit
Blocks
8 bits [24-31] 8 bits [16-23] 8 bits [08-15] 8 bits [00-07]
Bit # 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Decimal 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Binary 0 0 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0

 

EVERYTHING IN BETWEEN WHERE X IS EITHER 1 OR 0
Start IP 32 0 0 0
8 Bit
Blocks
8 bits [24-31] 8 bits [16-23] 8 bits [08-15] 8 bits [00-07]
Bit # 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Decimal 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Binary 0 0 1 0 0 0 0 0 X X X X X X X X X X X X X X X X X X X X X X X X

 

END
End IP 32 255 255 255
8 Bit
Blocks
8 bits [24-31] 8 bits [16-23] 8 bits [08-15] 8 bits [00-07]
Bit # 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 09 08 07 06 05 04 03 02 01 00
Decimal 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1 128 64 32 16 8 4 2 1
Binary 0 0 1 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

 

How does one calculate a CIDR?

The answer depends on which side you work from -- if you are trying to calculate an IP range from a CIDR or a CIDR from an IP range. Let's look at both:

IP range -> CIDR

Example #1 - Just two IPs

Let's start simple.

What is the CIDR for XX.XX.XX.0 to XX.XX.XX.1 (A range of just two IP numbers)

In binary, we know that this means the last bit can be either a 1 or a 0

Since the IP is made up from 32 binary bits, the answer is 32 bits less 31 bits equals one bit, so the answer is:

XX.XX.XX.0/31

Example #2 - 10 Ips

Now what if we wanted XX.XX.XX.0 thru XX.XX.XX.9 (A range of 10 IP numbers)

Now it gets a bit more complicated:

Because a CIDR can only express a power of 2, it can express 1, 2, 4, 8, 16, 32, 64 etc. However, you cannot express the numbers in between (like 3, 5, 6, 7, 9, 10 etc) as CIDR.

The solution is to use two or more CIDR expressions to get the number to work:

XX.XX.XX.0/29 : (32 bits less 29 bits) is 2 to the power of 3 which is 8 AND
XX.XX.XX.8/31 : This is 2 as per example #1.

Answer: 8 + 2 = 10.

CIDR -> IP range

By now you have probably figured out that this is the reverse of the above and it's actually easier in a sense.

XX.XX.XX.0/24 means take 32 bits, subtract 24 (leaving 8) and use that as the two's power.

Answer: 256

Therefore the IP range is XX.XX.XX.0 thru XX.XX.XX.255 (remember 0 is also one of the IP addresses)

CIDR Names

CIDRs are also have names. The names are called network classes.

CIDR Class
/8 A
/16 B
/24 C
Download the IP to Country Database, CIDR ranges or calculate IP to CIDR or CIDR to IP arange here

 


Copyright 2002- Webnet77.com. All Rights reserved.