Author: Jitendra Bafna
CIDR stands for Classless Inter Domain Routing is also known as super netting is a method allocating IP Addresses which improves the efficiency of IP Address distribution and replaces the class based (Class A, Class B and Class C) IP distribution.
- Class A, with over 16 million identifiers
- Class B, with 65,535 identifiers
- Class C, with 254 host identifiers
Let’s consider an organization requiring around 500 IP Addresses or Host. In such cases, organizations have to go with a Class B IP distribution system where almost more than 60,000 IP addresses are wasted.
What is IP Address?
IP Addresses consist of two groups in bits in address, the most significant bits are network prefix which identifies network or (subnet) and least significant bits from host identifier which specifies particular interface of host on that network.
IP Addresses have 2 components: 1.) Network Address 2.) Host Address
Each IP Address (IPv4) is 32 bit or 4 Octet. Below is the representation of IP Address in Binary
CIDR Block Notation: – xxx.xxx.xxx.xxx/n, where n is number of bits used for subnet mask.
Subnet Mask is made up of setting up all network bits to all 1’s and host bits to all 0’s.
Let’s consider, if you provide CIDR Block 192.168.0.0/24, it will give 255 host or IP address.
|CIDR Notation||Total Host|
What is Subnet?
A subnetwork or subnet is a logical subdivision of an IP network. The practice of dividing a network into two or more networks is called subnetting. Computers that belong to a subnet are addressed with an identical most-significant bit-group in their IP addresses.
Now, we will see how to Calculate total number hosts using Subnet Mask.
Use Case 1
Subnet Mask 192.168.0.0/24 will equate to IP Range 192.168.0.0 – 184.108.40.206.
N represents Network and H represents Host. In the above example, we made 24 bits to 1’s and the remaining 8 bits to 0’s because the Subnet Mask end range is 24. Total 0’s are 8 for Host (2*2*2*2*2*2*2*2=256)
This will give an IP range of 192.168.0.0 – 192.168.9.255 (Total 256 Hosts).
Use Case 2
Subnet Mask 192.168.0.0/23 will equate to IP Range 192.168.0.0 – 220.127.116.111.
N represents Network and H represents Host. In the above example, we made 23 bits to 1’s and the remaining 9 bits to 0’s because the Subnet Mask end range is 23. Total 0’s are 9 for Host (2*2*2*2*2*2*2*2*2=512)
This will give an IP range of 192.168.0.0 – 192.168.0.511 (Total 512 Hosts).
Use Case 3
Subnet Mask 192.168.0.0/27 will equate to IP Range 192.168.0.0 – 192.168.0.31
N represents Network and H represents Host. In the above example, we made 27 bits to 1’s and the remaining 5 bits to 0’s because the Subnet Mask end range is 27. Total 0’s are 5 for Host (2*2*2*2*2=32).
We have borrowed 3 bits from the host to make a total 27 bits. So Subnet will be (2*2*2=8) and Host will be 32. So we can get a total of 8 subnets.
Subnetworks will be 192.168.0.0/27, 192.168.0.31/27, 192.168.0.63/27, 192.168.0.95/27, 192.168.0.127/27, 192.168.0.159/27, 192.168.0.191/27, 192.168.0.223/27
Here we are dividing the subnet mask into smaller subnetworks.
Whenever you are creating MuleSoft VPC, you need to make sure whatever CIDR Mask you are providing doesn’t conflict with your on premise or any other networks.
The smallest network subnet block you can assign for your Anypoint VPC is /24 and the largest /16.
For each worker deployed to CloudHub, the following IP assignation takes place:
- For better fault tolerance, the VPC subnet may be divided into up to four Availability Zones.
- A few IP addresses are reserved for infrastructure (at least 2 IP Addresses).
- At least two IP addresses per worker to perform at zero-downtime.
MuleSoft VPC Sizing
Now, we learn how we can do the VPC sizing. Below are some requirements:
- You have three environments dev, test, sit and prod.
- Application on dev and sit must run on 1 Worker.
- Application on the test must be run on 2 Workers.
- Application on prod must run on 2 Workers.
- Total Application = 100 (Near Future)
- Organization will have 2 VPC’s, one for PROD and another for NON PROD.
Problem statement is that we need to decide the minimum CIDR block that will be needed for PROD and NON PROD VPC.
|Environment||Production VPC||Non Production VPC|
|Dev||100*1 Worker =100|
|SIT||100*1 Worker =100|
|Test||100*2 Worker =200|
|Additional IP Address required for zero downtime (50% of Total)||100||200|
There will be 2 IPs reserved for each VPC for infrastructure.
For Production VPC, we require around 300 IPs and it will be provided by a subnet mask of /23 (e.g. 192.168.0.0/23). This subnet mask will provide 512 IPs.
For Non Production VPC, we require around 600 IPs and it will be provided by a subnet mask of /22 (e.g. 192.168.0.0/22). This subnet mask will provide 1024 IPs.
You should know how you can make use of the CIDR range efficiently and perform MuleSoft VPC sizing.