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 FreeHello, Muleys!
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
xxxxxxxxxx
XX.YY.ZZ.AA/32 --> 1 IP
xxxxxxxxxx
0.0.0.0/0 --> All IP's
We can define anything between 0 to 32 range. CIDR consists of 2 components: Base IP (xx.yy.zz.aa) and Subnet Mask (/26)
xxxxxxxxxx
192.134.0.0/29
192.134.0.0 is the Base IP address range
/29 is the Subnet Mask
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.
Calculated as:
xxxxxxxxxx
/32 -- 2^0 -- 1 IP
/31 -- 2^1 - 2 IP
/30 -- 2^2 - 4 IP
.
.
.
/0 -- 2^32 -ALL IPs
How did we calculate?
Calculation Details for 192.134.0.0/29
- CIDR: 192.134.0.0/29
- IPs in Range: 8 ( 2^ 32-29 = 2^ 3 =8)
- Mask Bits: 29
- CIDR IP Range: (192.134.0.0 - 192.134.0.7 ) i.e, 192.134.0.0,192.134.0.1,192.134.0.2,192.134.0.3,192.134.0.4,192.134.0.5,192.134.0.6,192.134.0.7, 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.
Comments