CIDR – Classless Inter-Domain Routing, also called as supernetting.
IP addresses were originally assigned in four major address classes: A, B, C and D. CIDR was introduced CIDR in 1993 to replace classful network design for better to efficiently use IP addresses.
|Class||IP Range||Default Subnet Mask||Number of hosts||CIDR Notation|
- For class A first 8 bits tells the network and remaining bits can be used to identify hosts in that network.
- For class B first 16 bits are assigned for the network address and rest are used to identify hosts.
- In CIDR notation /8 means last 8 bits are used to identify host address and remaining (32-8) are used to identify network.
- Trailing zeroes in CIDR notation can be dropped, example 18.104.22.168/24 can be written as 192.0.16/24.
- CIDR is also used for IPv6 addresses but the prefix length will vary from 0 to 128.
Advantages of using CIDR Notation
- Earlier companies were allocated Class B network block (most popular block for companies) which covered a lot of IPs and it was not very efficient because Class B block will provide 65,534 addresses and a company may not want to use all those IPs. With CIDR if a company needs just 15,000 addresses they can be assigned /18 prefix with will give them 16,384 addresses instead of taking a whole lot of 65,534 addresses.
- Network descriptions can be represented by a single entry and reduces the number of network table entries.
- Example: Comcast Corporation is assigned 22.214.171.124/8 address.
How are IP address allotted? Who governs it?
- Internet Assigned Numbers Authority (IANA) manages allocation of IP address globally. It allocates blocks of IPs to RIR.
- Earth is divided into 5 regions. Each country belongs to one of these regions.
- A regional Internet registry (RIR) is an organization that manages the allocation of IPs within a region.
- Example ARIN (American Registry for Internet Numbers, an RIR) serves the US and Canada.
- RIR further allocates IP blocks to LIR (Local Internet Registry). LIRs are local ISPs.
Subnetting: What are subnets?
Dividing a larger network into smaller networks is called subnetting. Why do we have to do it? You might have to assign a unique network to a set of business, application, etc. You would like the system to be maintainable a problem in one component should be isolated to that subnet only. There are security advantages. There are performance gains as well.
What is a subnet mask?
A subnet mask is a 32-bit value which helps to separate network address from the host address. Just by looking at an IP address you cannot determine the network ID of the IP. If a subnet is not defined then the default subnet mask is used which is in the above table for Class A, B, C addresses. A valid subnet mask consists of only consecutive 1’s and then 0’s.
The first (generally) address of any network is reserved for subnet address and the last one is reserved for broadcast address, that’s why for /27 network number of IPs available for using are 25-2 which is 30.
What is a subnet address?
In a subnet address, all host bits are set to the value 0. The network address is not assigned to any router or host.
For example: for subnet mask 255.255.255.0 (default subnet mask for Class C): This means the first 3 octets will be the same for all IPs in the same network (note there are all 255). This subnet can have 256 addresses (or 254 host IPs). So IP 126.96.36.199 and 188.8.131.52 belong so same subnet but NOT 184.108.40.206, because 3rd octet of this IP is different.
What is a broadcast address?
In a broadcast address, all the host bits are set to the binary value 1. Broadcast as the name suggest is used to send data packets to all hosts in the subnet.
How to check if two IPs are in the same subnet?
If you have two IPs lets say 192.168.1.17 and 192.168.1.14
If the subnet mask is /28 then it is 255.255.255.240, do they belong to the same subnet?
Subnet /28 means the first 28 bits of IP should be exactly the same, the last 4 bits can be anything. So let’s convert IP addresses of hosts in binary format.
192.168.1.17 —> 11000000.10101000.00000001.00010001
192.168.1.14 —> 11000000.10101000.00000001.00001110
As we can see the first 28 bits are not the same so they do not belong to the same subnet.
|Prefix||Network mask/Subnet||Usable hosts per subnet|
|Class A Network|
|Class B Network|
|Class C Network|