Published on: October 6, 2010 by Jithin Vijayan
Increasing growth of Internet created a high demand for IPs and made the job of IP allocation a tougher one. To avoid this situation of requesting additional IP addresses was avoided by the introduction of IP subnetting. The IP subnetting was introduced so that the local network will be more adaptable to changes when a new physical media is installed, when it has to be split into two or more networks. Say for example in an office if they needs a seperate network for the administrative purpose and which should not get interfered with the office purpose ones. But the main purpose of IP subnetting is to reduce the heavy traffic loads. Security can also be increased with subnetting by preventing access to a particular network from others. Basically it allows a single shared network to connect to the internet so that the organisation will have multiple connections without having any extra IP address space.
Though job of IP subnetting is done locally it still appears as one IP network for outside world. As said the subnetting is done locally, the part which is used for subnetting is the host part. It divides the host part again into subnetid and hosts which makes the IP format like
<Network part><subnet id><host part>
Process of subnetting a network
Subnetting a network in simple words is representing network bits by 1s and host bits by 0s. As mentioned earlier we divide host bits for subnetting so we are reducing the host ID for the subnet ID. Class A have 24 bits to split, Class B has 16 and Class C have only 8. Let’s take a Class B IP for instance.
172.16.5.1 here (172.16) is the network part and (5.1) represents host. IP’s are subnetted bitwise, one bit subnetting will have 1 bit for subnet id and rest 15 for host part. Let me explain this in figures
1 bit subnet – <1 subnet id > <15 host ids>
2 bit subnet – <2 subnet id > <14 host ids>
3 bit subnet – <3 subnet id > <13 host ids>
and so on. Here if we take 5 bit subnetting for this IP, subnetting will be done in
172.16.5.1 bitwise representation 10101100.00010000.00000101.00000001
subnetting 5 bits – 10101100.00010000.00000|101.00000001
The number of sub-networks created will be equal to (2^n) where n is the number of bits borrowed to network portion. Here it is 5 so
2^5 = 32
Number of hosts per subnet is calculated by formula (2^n)-2 where n is the number in host bits. (2 subtracted is for, one is the network id which is the first IP in the network and last one will be the broadcast ip). i.e All 1’s and all 0’s are not permitted for subnets.
A bit mask, known as the subnet mask, is used to identify which bits of the
original host address field indicate the subnet number. The number is calculated by representing the network part with ones and the rest with zeroes. The subnet mask for the above IP will be
1-21 bits are the network part they will be represented in ones and rest 22-32 in zeroes
Decimal notation will be 255.255.248.0
255.255.248.0 is the subnet mask of the the subnetting we done for the IP 172.16.5.1.
The above case is just an example as subnetting is done for a required number of hosts per subnets.
We can calculate the network id by performing a bitwise logical AND operation between the IP address and the subnet mask, then setting all the host bits to 0s. Similarly, the Broadcast Address for a subnet by performing the same logical AND between the IP address and the subnet mask, then setting all the host bits to 1s.
Decimal notation – 172.16.0.0 will be the network id and 172.16.31.255 will be the broadcast address.
The above subnetting done is an example of static subnetting but there are some setbacks when the subnets are divided statically. Consider a corporation where a Class C network IP 22.214.171.124 is assigned and they have a requirement to split this into 5 separate networks. And let each network has a prerequisite of
Subnet 1 : 50 hosts
Subnet 2: 50 hosts
Subnet 3: 40 hosts
Subnet 4: 30 hosts
Subnet 5: 20 hosts
The above cannot be achieved with the subnetting which we done earlier. Static subnetting can divide network into four subnets each with 64 hosts or eight subnets each with 32 hosts. This doesn’t meet our prerequisite. Here the entire network cannot have same subnet mask . To avoid such situations we divide the network into different subnets according to the requirement. For the above it can be done
The first three subnets can be divided with a mask of 255.255.255.192 the network can be divided into four subnets each with 64 hosts. The last two can be divided into two subnets each with 32 hosts by using a mask of 255.255.255.224 . This satisfies the requirement also by eliminating the possibility of high number of wasted host addresses.
Classless Addressing: Classless Inter-Domain Routing
It is a methodology of allocating IP addresses and routing Internet Protocol packets. This method was introduced to keep Internet from running out of IP addresses. Though the concept of subnetting addressed a major difficulties in classful addressing they couldn’t tackle the problem in general terms. Anyone having a requirement of more than a 254 host addresses were given Class B address block which have 65534 host addresses. This is really unacceptable at this point of time where the requirement of Ips are on a high. The method of classless addressing was introduced to avoid the crisis.
Each CIDR routing table entry contains a 32-bit IP address and a 32-bit network mask, which together give the length and value of the IP prefix. This is represented as <IP_address network_mask>. For example, to address a block of eight Class C addresses with one single routing table entry, the following representation suffices: <126.96.36.199 255.255.248.0>.
i.e Class C network range from 188.8.131.52 to 184.108.40.206 is represented as one single network.
11000000 00100000 10001000 00000000 = 220.127.116.11 (Class C address)
11111111 11111111 11111— ——– = 255.255.248.0 (network mask)
11000000 00100000 10001— ——– = 192.32.136 (IP prefix)
11000000 00100000 10001111 00000000 = 18.104.22.168 (Class C address)
11111111 11111111 11111— ——– = 255.255.248.0 (network mask)
11000000 00100000 10001— ——– = 192.32.136 (same IP prefix)
The process of combining multiple entries into a single network is known as supernetting.
The above IP is also represented in another notation 22.214.171.124/21 where 21 means network has 21 bits for network id and 11 bits for host id. Perhaps this is the widely used notation better known as CIDR notation. The following figure will explain this better.
Category : General, Linux, Training