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.

ClassIP RangeDefault Subnet MaskNumber of hostsCIDR Notation
A1-126.X.X.X255.0.0.0224-2/8
B128-191.X.X.X255.255.0.0216-2/16
C192-223.X.X.X255.255.255.028-2/24
D224-239.X.X.X
E240-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.

PrefixNetwork mask/SubnetUsable hosts per subnet
/1128.0.0.02,147,483,646
/2192.0.0.01,073,741,822
/3224.0.0.0536,870,910
/4240.0.0.0268,435,454
/5248.0.0.0134,217,726
/6252.0.0.067,108,862
/7254.0.0.033,554,430
Class A Network
/8255.0.0.016,777,214
/9255.128.0.08,388,606
/10255.192.0.04,194,302
/11255.224.0.02,097,150
/12255.240.0.01,048,574
/13255.248.0.0524,286
/14255.252.0.0262,142
/15255.254.0.0131,070
Class B Network
/16255.255.0.065,534
/17255.255.128.032,766
/18255.255.192.016,382
/19255.255.224.08,190
/20255.255.240.04,094
/21255.255.248.02,046
/22255.255.252.01,022
/23255.255.254.0510
Class C Network
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522
/31255.255.255.2540
/32255.255.255.2550

+ There are no comments

Add yours