Вы находитесь на странице: 1из 9

An Easy Guide to CIDR We know that if we use default subnets that the IP Addresses for each class is broken

down in Network ID (N) and Host ID (H) as per below:


NNNNNNNN . HHHHHHHH . HHHHHHHH . HHHHHHHH

255 .
NNNNNNNN .

0.
NNNNNNNN .

0.
HHHHHHHH .

0.
HHHHHHHH

Class A

255 .
NNNNNNNN .

255 .
NNNNNNNN .

0.
NNNNNNNN .

0.
HHHHHHHH

Class B

255 .

255 .

255 .

0.

Class C

This would be great if we wanted to have subnets that only need the default number of hosts available, but it isnt always the case. This is where Classless Inter Domain Routing comes into play or CIDR. CIDR allows us to tweak how many hosts are on a subnet, thus helping reduce the volume of network traffic and potentially make it easier to manage. Whats it look like? Normally it would look something like this: /27 But this would be tagged on the end of an IP address so would really look like: 192.168.2.12/27 The /27 tells us how many bits of an IP address is being used as the Network ID; the remainder would be used for the host ID. As an IPv4 address is 32-bits, if we continue the above example 27-bits will be used for the Network ID and the remaining 5-bits for the host ID: 32 27 = 5

Lets put it in to practice For this example well start with something you already know a Class A default Subnet mask 255.0.0.0 and Im going to break it down in to its octets in the table below: Octet 1 2 3 4 Decimal 255 0 0 0 128 64 32 16 8 4 2 1

Then starting from the left Im going to add up the numbers in the column headings until I get the figure in the decimal column. For every column I use Im going to put a 1 in the box: Octet 1 2 3 4 Decimal 255 0 0 0 128 1 0 0 0 64 1 0 0 0 32 1 0 0 0 16 1 0 0 0 8 1 0 0 0 4 1 0 0 0 2 1 0 0 0 1 1 0 0 0

128+64+32+16+8+4+2+1 = 255 Then lets add another column on the end and add the ones together: Octet 1 2 3 4 Decimal 255 0 0 0 128 1 0 0 0 64 32 1 1 0 0 0 0 0 0 Grand Total 16 1 0 0 0 8 1 0 0 0 4 1 0 0 0 2 1 0 0 0 1 1 0 0 0 Total 8 0 0 0 8

8+0+0+0 = 8 So a default Class 1 subnet mask could be written in CIDR notation as /8

Lets have a look at the steps for a Class B without an explanation and see if you can get it: Octet 1 2 3 4 Octet 1 2 3 4 Octet 1 2 3 4 8+ 8 Decimal 255 255 0 0 Decimal 255 255 0 0 Decimal 255 255 0 0 + 0 128 64 32 16 8 4 2 1

128 1 1 0 0 128 1 1 0 0

64 1 1 0 0

32 1 1 0 0 16 1 1 0 0

16 1 1 0 0 8 1 1 0 0

8 1 1 0 0 4 1 1 0 0

4 1 1 0 0 2 1 1 0 0

2 1 1 0 0 1 1 1 0 0

1 1 1 0 0 Total 8 8 0 0 16

64 32 1 1 1 1 0 0 0 0 Grand Total = 16

+ 0

So a Class B default subnet in CIDR notation looks like /16

Ill leave the Class C one blank for you to work out: Octet 1 2 3 4 Octet 1 2 3 4 Octet 1 2 3 4 + Decimal 128 64 32 16 8 4 2 1

Decimal

128

64

32

16

Decimal

128

64

32

16

Total

Grand Total + + =

So the CIDR Notation is ..

Lets ramp it up a bit Were not really going to use CIDR for default subnets, so what if were given a CIDR notation and want to know the dotted decimal version. Well use the one of the tables from above again: Octet 1 2 3 4 Decimal 128 64 32 16 8 4 2 1

And lets use the IP address from up near the top again - 192.168.2.12 /27 So we know that the 27 refers to the number of bits for the network. Starting from the top left white cell put a one in each cell until you get to 27: Octet 1 2 3 4 Decimal 128 1 1 1 1 64 1 1 1 1 32 1 1 1 1 16 1 1 1 8 1 1 1 4 1 1 1 2 1 1 1 1 1 1 1

For each row look if there is a 1 in the cell add the appropriate column headings together. Octet 1 2 3 4 Octet 1 2 3 4 Decimal 128 1 1 1 1 128 1 1 1 1 64 1 1 1 1 64 1 1 1 1 32 1 1 1 1 32 1 1 1 1 16 1 1 1 16 1 1 1 8 1 1 1 8 1 1 1 4 1 1 1 4 1 1 1 2 1 1 1 2 1 1 1 1 1 1 1 1 1 1 1

Decimal 255 255 255 224

Octet 1 = 128+64+32+16+8+4+2+1 = 255 Octet 2 = 128+64+32+16+8+4+2+1 = 255 Octet 3 = 128+64+32+16+8+4+2+1 = 255 Octet 4 = 128+64+32 = 224 Therefore the dotted decimal notation would be 255.255.255.224

Try this one for yourself 192.168.6.87 /29 Octet 1 2 3 4 Decimal 128 64 32 16 8 4 2 1

Dotted decimal = Now for the Evil Knievel Stuff So far youve seen how to convert a non-default decimal to a CIDR notation and vice versa, for the next stage well be putting it to use. But first a little refresher.. The first IP address in a network is classed as the Network ID and the last IP address is classed as the Broadcast address. In a class C network with the following IP address 192.168.3.n the Network ID would be 192.168.3.0; and the Broadcast address would be 192.168.3.255. Its important to know this as we can not allocate these addresses out to hosts. One of the main reasons we want to be able to interpret these, particularly for exams, is so we can tell if 2 hosts are on the same subnet or not; because if they are not they will not be able to talk to each other easily. To do this we have to work out where each subnet starts and finishes. So lets rev up the Harley Davidson and lets have a go. Well use the IP address from above again, as you are on good terms with each other now: 192.168.2.12 /27 This first bit will be familiar to you. So we know that the 27 refers to the number of bits for the network. Starting from the top left white cell put a one in each cell until you get to 27 and put in the decimals: Octet 1 2 3 4 Decimal 255 255 255 224 128 1 1 1 1 64 1 1 1 1 32 1 1 1 1 16 1 1 1 8 1 1 1 4 1 1 1 2 1 1 1 1 1 1 1

Now look at the very last number 1 you put in: Octet 1 2 3 4 Decimal 255 255 255 224 128 1 1 1 1 64 1 1 1 1 32 1 1 1 1 16 1 1 1 8 1 1 1 4 1 1 1 2 1 1 1 1 1 1 1

Then look at the column heading for the column it is in: Octet 1 2 3 4 Decimal 255 255 255 224 128 1 1 1 1 64 1 1 1 1 32 1 1 1 1 16 1 1 1 8 1 1 1 4 1 1 1 2 1 1 1 1 1 1 1

This gives me the number 32. Im going to leave that number to one side for now. We need to find out which octet we are going to be working with. The easiest way to do this is to put the decimal subnet below the IP address: IP Address Subnet Increment? 192 255 168 255 2 255 12 224

Then work out if the increments will take place in a particular octet. To do this look at the subnet mask. If it says 255 in the column put an N in the column. If it says any other figure then put a Y in it: IP Address Subnet Increment? 192 255 N 168 255 N 2 255 N 12 224 Y

From this I can tell that I need to work with the 4th Octet and the remaining part of the IP address remains the same 192.168.2.y; and we will increment the y to find the start of each subnet. The y will always start at 0. So the first subnet will start at: 192.168.2.0 But where will the next one start? Well remember the number 32 that we put to one side? Thats where the next one starts: 192.168.2.32

For the 3rd subnet we increase it by 32 again 192.168.2.64 And so on. As well as being the start of the subnets these are the Network IDs so Im going to put them in a table for ease of reference: Subnet 1 2 3 4 Network ID 192.168.2.0 192.168.2.32 192.168.2.64 192.168.2.96 Broadcast Address Host Range

We also know that the last IP address in a network is the Broadcast address. So to work out the Broadcast address for Subnet 1 we just deduct one from the start address of subnet 2 (192.168.2.32) so that gives us 192.168.2.31; and we continue that down: Subnet 1 2 3 4 Network ID 192.168.2.0 192.168.2.32 192.168.2.64 192.168.2.96 Broadcast Address 192.168.2.31 192.168.2.63 192.168.2.95 192.168.2.128 Host Range

The host range is all the addresses that fall between the Network ID and the Broadcast Address Subnet 1 2 3 4 Network ID 192.168.2.0 192.168.2.32 192.168.2.64 192.168.2.96 Broadcast Address 192.168.2.31 192.168.2.63 192.168.2.95 192.168.2.128 Host Range 192.168.2.1 192.168.2.30 192.168.2.33 192.168.2.62 192.168.2.64 192.168.2.94 192.168.2.97 192.168.2.127

Time for you to try it alone: 192.168.3.32 /28 Octet 1 2 3 4 Decimal 128 64 32 16 8 4 2 1

IP Address Subnet Increment? Increments by: Subnet Network ID 1 2 3 4 Broadcast Address Host Range

Вам также может понравиться