Getting Started With VPC (Virtual Private Cloud) - Part Two

In this article, which is  part of series of articles around VPC, we are going to learn about IP addresses and will be covering the below topics:
  • Understanding IPv4 addressing
  • Understanding private IP ranges.
  • Understanding classful subnet mask.
  • Understanding CIDR notation.


In AWS, every EC2 instance we launch gets both a public and a private IP address. Now the private IP address gets created from the subnet of the availability zone under which we have created the EC2 instance.
  • If we don’t select the subnet while creating EC2 instance, then it will be assigned to the default subnet.
  • To understand IP address, we can say that it is the decimal representation of the binary numbers.
  • IP address consists of 4 Octets and a total of 32 bits.
Below is the complete range of IPv4 Address.
Regarding public IPs, they have their own range and they are managed by the Internet Service Providers.
AWS Cloud provider has a huge public IP address ranges and from that range we get our public IP for the EC2 instances.
Now let’s see the Private IP ranges.


The 32-bit IP address is divided into five sub-classes. These are,
  • Class A
  • Class B
  • Class C
  • Class D
  • Class E
Each of these classes has a valid range of IP addresses. Classes D and E are reserved for multicast and experimental purposes respectively. The order of bits in the first octet determines the classes of IP address.
Now let’s see the IP address ranges for each of the classes.
Class A –
Class B –
Class C –
We are going to design the subnets with the private IPs, not public IPs, because if we use public IPs then it may conflict with the public IPs provided by internet service provider.
There is a misconception that we use subnet mask with Class C , with Class B and with Class A but this is not right;  we can use any subnet mask with any class.
Now let’s see what this subnet mask does to the IP address.
For example, if the IP address is  and subnet Mask is
Now we need to answer a few questions looking at the subnet mask.
  • What is the first IP or network address in this network?
  • What is the last IP or broadcast address in this network?
  • What is the gateway IP in this network?


By looking at the subnet mask we can see that first 3 octets are full.
So, the entire IP address range will start from to in this network.
What is the first IP or network address in this network?
First IP is also called network address and will be
What is the last IP or broadcast address in this network?
Last IP is called broadcast address and will be
What is the gateway IP in this network?
Next IP after First IP is assigned for the gateway and will be
Thus, the actual usable IP address range would be from to .
Total Possible IP addresses in the network will be 0-255 = 256 IP addresses.
Let’s take another example, Example 2:
IP Address
Subnet mask
Similarly, as seen in the previous example, we can calculate the values as follows:
First IP (Network address)
Usable IP ranges,,
. . . . . . . . .
. . . . . . . . .
. . . . . . . . .,
. . . . . . . . .
. . . . . . . . .
. . . . . . . . . and it will go on…till 
Last IP (Broadcast address)
As the last 2 octets of subnet mask are free so we can fill that, and any octet starts from 0 and ends at 255.
Total possible IPs = 256*256 =65K approx. ,if we are going to use subnet mask.
IP Address
Subnet mask
Now we can easily derive the values,
First IP (Network address)
Usable IP ranges -
Last IP (Broadcast address) 10. 255. 255.255
Total possible IPs = 256*256*256 = 16777216
So now by looking at subnet mask we can tell all these things.
We can also use online IP subnet calculator as seen below.


For Subnet mask, its binary conversion will be 11111111.00000000.00000000.00000000 out of all this binary format we have eight 1s, so CIDR notation will be CIDR = /8
Example 2
Subnet mask
Binary conversion 11111111. 11111111.00000000.00000000
CIDR = /16
Example 3
Subnet mask 255.255. 255.0
Binary conversion 11111111. 11111111. 11111111.00000000
CIDR = /24
Nowadays we have started using CIDR in place of writing complete subnet mask as 255.255. 255.0.


In this article we learned the IPv4 addressing and saw subnets, and classful subnet mask CIDR notation. In the next article we will be using these concepts in practical implementation.
I hope you find this article helpful. Stay tuned for more … Cheers!!