CLOUD COMPUTING: VPC NETWORKS, MASKING, SUBNETWORKS, CIDR RANGES AND WHATEVER CONFUSION THEY MAY BRING (PART 2)
In the first part of this network series, I wrote about the building blocks of virtual private cloud (VPC) networking. The different classes of network were briefly discussed and the concept of masking was discussed. For this part, I will be writing about subnets and the hurdles that I personally go through in setting up a custom network in GCP. If you haven’t read the first part, chances are you might find this to be confusing. Read it here…
So, Subnets? Subnetworks? What is Subnetting?
A typical network class has 3 standard host ID sizes: Class A (24bits), Class B (16bits) and Class C (8bits). But in practice, these standard sizes are not economical. For instance, a 24bits host ID is capable of supporting a maximum of 2²¹ (2,097,152) host IDs. With few of these IDs in use, the rest becomes wasted resources. With subnetting however, we get to go beyond the standard host ID sizes and determine our own desired sizes.
The basic meaning of a subnetwork is as the name suggests; a type of a smaller network gotten from the division of a network. They are created with the use of masking, just that this time around, the Host IDs are tweaked.
For instance, the standard network masking for the Class C network, 184.108.40.206 is 255.255.255.0. This will give 2²¹ network IDs and (2⁸–2) hosts. 255.255.255.0 as used here is standard, but with subnetting, we could use 255.255.255.244.
Let’s draw up a table;
From the table above, the three bits therein called SUB have been used to create a subnetwork from the host ID gotten from the masking. This means that the network is capable of having 8 (2³) subnetworks. This leaves us with 30 (2⁵ -2) host IDs. The resulting subnet table is as shown below;
Note: Hosts of all zeros and all 1s are reserved.
The subnet mask as described above has two ways of representation;
1. Either we say that the address 220.127.116.11/255.255.255.244 has a subnet mask of 3-bits, or
2. We use classless inter-domain routing (CIDR) method and simply represent it as 18.104.22.168/27.
How come the /27? Well, the 27 represents the number of bits set in the mask.
Moving on, remember when I said subnetting helps control IDs? Let’s try it out.
Assume we are working with a Class C network (22.214.171.124) with its mask having 11110000 as its last 8 bits. The first 4 bits are SUB bits, the rest are host ID bits.
Number of subnets: 16(2⁴)
Number of hosts: 14 2⁴–2)
Number of subnet hosts for 126.96.36.199/28: 16 x 14 = 224
For 11000000 with 2 bits for subnets and 5 bits for hosts
Number of subnets: 4(2²)
Number of hosts: 62(2⁶–2)
Number of subnet hosts for 188.8.131.52/26: 4 x 62 = 248
How about 11111000 with 5 bits for subnets and 3 bits for hosts?
Number of subnets: 32(2⁵)
Number of hosts: 6(2³–2)
Number of subnet hosts for 184.108.40.206/29: 32 x 6 = 192
Let’s conclude this part with an example:
A network address 172.16.0.0 is masked with 255.255.248.0. Determine the number of subnets and hosts. Also, what is the CIDR representation?
Note: It is a Class B network.
Number of subnets: 32 (2⁵)
Number of hosts: 2046 (2¹¹–2)
CIDR representation: 172.16.0.0/21
2046 hosts! That has got to be much right? How about we do a reverse calculation with the second example? In this example, we will be given two IP addresses and we will be asked to check if they belong to the same subnetwork.
Given two devices with different IP addresses: A(172.16.17.30/20) and B(172.16.28.15/20). Determine if they are on the same subnet.
From the CIDR representation, we can tell it is a Class B network and the netmask is 11111111.11111111.11110000.00000000. The decimal equivalent of 11110000 is 240.
They do belong to the same network don’t they?
We will continue in PART 3.
Have you read PART 1?