Understanding CIDRs and Public vs Private IPs
We use CIDR ranges for security-related things. Like to secure the traffic in terms of IP addresses. Usually, it helps us in defining the IP address range.
Join the DZone community and get the full member experience.Join For Free
We often hear about CIDR (spelled as /ˈsaɪdər, ˈsɪ-/) when we encounter AWS terms or when configuring VPC's in MuleSoft. So this article basically helps you to understand what CIDRs are and how to calculate the range of IP addresses etc.
We use CIDR ranges for security-related things. Like to secure the traffic in terms of IP addresses. Usually, it helps us in defining the IP address range
As we all know, MuleSoft's cloud hub applications are deployed in AWS internally so we should be familiar with the notation of CIDR w.r.t AWS.
Usually, the notation for CIDR is
We can define anything between 0 to 32 range. CIDR consists of 2 components: Base IP (xx.yy.zz.aa) and Subnet Mask (/26)
Base IP: Represents the IP address contained in that range
Subnet Mask: Defines how many bits can change in the IP
The subnet has two forms of representation: In windows, it is usually denoted as
255.255.255.0 (less commonly used). In AWS terms, it is denoted as
/29 (most commonly used)
Subnet: It basically gives the additional next values of Base IP.
How did we calculate?
Calculation Details for
- CIDR: 184.108.40.206/29
- IPs in Range: 8 ( 2^ 32-29 = 2^ 3 =8)
- Mask Bits: 29
- CIDR IP Range: (220.127.116.11 - 18.104.22.168 ) i.e, 22.214.171.124,126.96.36.199,188.8.131.52,184.108.40.206,220.127.116.11,18.104.22.168,22.214.171.124,126.96.36.199, total of 8 IPs
- Mask Bits: 29
- Note: In Base IP, for IPv4 , we have a notation like w.x.y.z , 4 sections; each sections for eg: "w" can vary from 0 to 255 , likewise:
So the base IP is usually between the range of 0.0.0.0 to 255.255.255.255 (IPv4 range). Use this website here to calculate the CIDR range.
Public vs Private IPs
The Internet Assigned Numbers Authority (IANA) is a standards organization that oversees global IP address allocation. They define which range of IP addresses are public and can be accessed by everyone and what range of IP addresses are private and who can use them.
Hope this article helps you to understand the basics of CIDR and its calculation along with what is private and public IP's and their range.
Opinions expressed by DZone contributors are their own.