The Network address identifies a network on the internet. Using this, we can find a range of addresses in the network and total possible number of hosts in the network.
A mask is a 32-bit binary number that gives the network address in the address block when an AND operation is bitwise applied on the mask and any IP address of the block.
The default masks in different classes are:
Class A – 255.0.0.0
Class B – 255.255.0.0
Class C – 255.255.255.0
Example: Given IP address 132.6.17.85 and default class B mask, find the beginning address (network address).
Solution: The default mask is 255.255.0.0, which means that only the first 2 bytes are preserved and the other 2 bytes are set to 0. Therefore, the network address is 132.6.0.0.
Dividing a large block of addresses into several contiguous sub-blocks and assigning these sub-blocks to different smaller networks is called subnetting. It is a practice that is widely used when classless addressing is done.
A subnet or subnetwork is a network inside a network. Subnets make networks more efficient. Through subnetting, network traffic can travel a shorter distance without passing through unnecessary routers to reach its destination.
To reduce the wastage of IP addresses in a block, we use sub-netting. What we do is that we use host ID bits as network ID bits of a classful IP address. We give the IP address and define the number of bits for mask along with it (usually followed by a '/' symbol), like, 192.168.1.1/28.
Here, the subnet mask is found by putting the given number of bits out of 32 as 1, like, in the given address, we need to put 28 out of 32 bits as 1 and the rest as 0, and so, the subnet mask would be 255.255.255.240.
A classless addressing system or classless interdomain routing (CIDR or supernetting) is the way to combine two or more class C networks to create a /23 or a /22 supernet. A classless addressing system or classless interdomain routing (CIDR) is an improved IP addressing system. In a classless addressing system, the block of IP address is assigned dynamically based on specific rules.
Let's look at a simple example of how to convert an IP address from classful to classless notation:
def ip_classless(ipaddress): ''' Will return the Classless IP Address ''' # Gets the First Octet through String Slicing firstOctet = int(ipaddress[:ipaddress.index('.')]) if(0 <= firstOctet <= 127): # Means this is Class A IP Address return ipaddress + '/8' elif(128 <= firstOctet <= 191): # Means this is a Class B IP Address return ipaddress + '/16' elif(192 <= firstOctet <= 223): # Means this is a Class C IP Address return ipaddress + '/24' else: return "This is a reserved IP Address, INVALID!!"# Example usageip = "192.168.0.0"print(ip_classless(ip)) # Output: 192.168.0.0/24
This program takes an IP address in classful notation as input (e.g., 192.168.0.0) and converts it to classless addressing (CIDR notation) by checking the Class of the IP address and setting the mask (number after '/') on that basis.
Question: Given IP Address – 172.16.0.0/25, find the number of subnets and the number of hosts per subnet. Also, for the first subnet block, find the subnet address, first host ID, last host ID, and broadcast address.
Solution:
This is a class B address. So, number of subnets = 2^(25-16) = 2^9 = 512.
Number of hosts per subnet = 2^(32-25) – 2 = 2^7 – 2 = 128 – 2 = 126
For the first subnet block (Subnet Number=1), we have:
Efficient Use of IP Space: Classless addressing allows for more efficient use of the available IP address space by allocating only the necessary number of addresses to each network.
Flexible Subnetting: It provides flexibility in subnetting, allowing network administrators to create subnets of various sizes based on their specific needs.
Reduced Routing Table Size: CIDR helps in reducing the size of routing tables by allowing route aggregation, which combines multiple routes into a single entry.
Better Address Allocation: It enables more precise allocation of IP addresses, reducing wastage that was common in classful addressing.
Support for VLSM: Classless addressing supports Variable Length Subnet Masking (VLSM), which allows different subnets to have different subnet masks.
Classless addressing, also known as Classless Inter-Domain Routing (CIDR), was introduced to overcome the limitations of classful addressing. It provides a more flexible and efficient way to allocate IP addresses and create subnets. By using a variable-length subnet mask, CIDR allows network administrators to allocate IP addresses in blocks of any size, rather than being restricted to the fixed sizes of Class A, B, and C networks.
This approach has significantly extended the usable life of IPv4 addressing by making more efficient use of the available address space. It also provides the foundation for modern routing protocols and network design practices.
Test Your Knowledge
Take a quiz to reinforce what you've learned
Exam Preparation
Access short and long answer questions for written exams