CIDR and basic subnetting
This particular aspect of networking/computer affects everyone with a network. It’s so unbelievably necessary for anyone who deals with networks (at any level) to understand. I cannot stress this enough! :) That said, so many people have serious problems with it and I can kind of understand why. Every single site I’ve seen goes into the detail straight away with binary arithmetic. Yes, binary arithmetic is how you work these things out, but are these people doing this binary arithmetic in their head when they know a /26 has a subnet mask of 255.255.255.192? Well, yes and no. They’re using a shorthand variety, they are not ANDing 1 and 0’s. Well, if they are, they’re wasting braincells.
Do you even know what I just said? No? Well read on… Warning : There’s very little point skimming this. It might be time to open up your calculator and grab a piece of paper and a cup of coke (ugh, I hate coffee).
So, a computer network is basically just a way for my computer to talk to another computer. If you need this part explained, it might be time to start reading somewhere else before continuing here. So on our IP based networks, machines have IP addresses. So, yadda yadda yadda, this uniquely identifies a machine on the network. I’m hoping noone needed that to be explained. If so, go read some background first. Of course, machines can have multiple IP addresses and even one IP address can represent multiple machines, but let’s keep it simple for the time being (if you don’t put these things in, the anoraks get very animated).
So back in the good ol’ days, when networks were easy we had what is known as … Park Life … ok, sorry, bad habit … classful networks. It’s surprising how many texts and papers (mostly out of date) still refer to Class A, B & C networks. These are obsolete and have been since about 1993 (ref: wikipedia - it’s great isn’t it?). So basically, these classful networks, i.e. what is commonly referred to as Class A, B & C have been out of date since anyone actually used the Internet. What the hell is up with people still referring to them then? I don’t know either. What is used now is CIDR - Classless Inter-Domain Routing. Don’t get too bogged down remembering it, just associate network segments with the slash terminology - /16, /24, /28 (pronounced “slash 16”, “slash 24”, “slash 28”) etc.
So what were classful networks about and why do we now have CIDR? Well, a network is great, but although we have one big network (the Internet) it’s actually divided up into many small segments. This is to facilitate many things. There have probably been many papers written on the benefits and right and wrong ways to segment networks but at the end of the day it makes logical sense that in some way the big network containing 2^32 IP addresses is broken up into smaller chunks that are more manageable. In the before time (i.e. before 1993) you (as a person who wanted an allocation of public IP addresses) could have three types of allocations. A class A (big allocation - like really big), a class B (medium sized) and a class C (small sized). These were fixed sizes, so a Class A was 16777216 (or 2^24 - that’s 2 to the power of 24) IP addresses, a class B was 65536 IP addresses (i.e. 2^16) and a class C was 256 IP addresses (i.e. 2^8).
Now, what about if someone wanted something in between a class C and a Class B (like say 20,000 ip addresses) ? Well, they’d either have to get allocated approximately 78 class C’s (20,000 divided by 256) or use a class B and waste 40k IP addresses. What if someone wanted 12 IP addresses? Well, they’d get a class C as well … eek. Ok, so we moved away from this technique to stop WASTING IP addresses. Why don’t we hand out IP addresses one at a time? Because that isn’t feasible & it makes sense to use logical blocks for a lot of reasons but especially routing ones. There’s a long winded explanation for that as well, so just ignore that question!
So, the CIDR format was used in order to facilitate chopping up network segments into smaller more configurable chunks. Now, this is the bit where we will need to start using some binary arithmetic, but don’t worry, I’ll try and guide you through it.
First and foremost: An IP address is 32 bits. In fact in networking, most things are represented in 32 bits as most computers can natively (or at least were, we’re moving towards 64 bit architectures now) store 32 bits. What does that mean? It means that the IP address 188.8.131.52 (the IP of this website) is stored as 32 1’s and 0’s.
IP addresses are composed of four parts (octets), so if an IP address is 32 bits, each octet is how many bits? (octet should give you a clue as well) … yup, ok it’s 8 (again, simple arithmetic, 32 divided by 4).
So, in 1’s and 0’s, the IP is broken up into: