CIDR and subnetting


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
A 1-126.X.X.X 255.0.0.0 224-2 /8
B 128-191.X.X.X 255.255.0.0 216-2 /16
C 192-223.X.X.X 255.255.255.0 28-2 /24
D 224-239.X.X.X
E 240-245.X.X.X
  • 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 192.0.16.0/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 73.0.0.0/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 193.1.1.2 and 193.1.1.6 belong so same subnet but NOT 193.1.3.2, 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
/1 128.0.0.0 2,147,483,646
/2 192.0.0.0 1,073,741,822
/3 224.0.0.0 536,870,910
/4 240.0.0.0 268,435,454
/5 248.0.0.0 134,217,726
/6 252.0.0.0 67,108,862
/7 254.0.0.0 33,554,430
Class A Network
/8 255.0.0.0 16,777,214
/9 255.128.0.0 8,388,606
/10 255.192.0.0 4,194,302
/11 255.224.0.0 2,097,150
/12 255.240.0.0 1,048,574
/13 255.248.0.0 524,286
/14 255.252.0.0 262,142
/15 255.254.0.0 131,070
Class B Network
/16 255.255.0.0 65,534
/17 255.255.128.0 32,766
/18 255.255.192.0 16,382
/19 255.255.224.0 8,190
/20 255.255.240.0 4,094
/21 255.255.248.0 2,046
/22 255.255.252.0 1,022
/23 255.255.254.0 510
Class C Network
/24 255.255.255.0 254
/25 255.255.255.128 126
/26 255.255.255.192 62
/27 255.255.255.224 30
/28 255.255.255.240 14
/29 255.255.255.248 6
/30 255.255.255.252 2
/31 255.255.255.254 0
/32 255.255.255.255 0

+ There are no comments

Add yours