IPv4 CIDR Calculator
Type your input below. This will automatically do the calculation.
CIDR stands for Classless Inter-Domain Routing.
IPv4 CIDR notation: [IPv4 network address]/[host identifier]
.
For example: 192.168.0.1/24
Calculation
Let's calculate this: 192.168.0.1/24
Break it down, we have two parts: 192.168.0.1
and /24
.
The 192.168.0.1
is an IPv4 dot-decimal notation. The network address.
The /24
is the subnet mask as a host identifier (to denote its own network).
This is a neat explanation.
This is the mainline of how the tool above does the calculation. Steps:
- Convert the IPv4 dot-decimal notation to dot-binary notation.
192.168.0.1
►11000000.10101000.00000000.00000001
- Translate the subnet mask suffix, in above example:
/24
, into dot-binary notation.
The total length of the notation is 32 bits (32 of 0's and/or 1's).
Look at the number after the slash, it is 24. Meaning we create 24 of 1's from the left (24 leading 1-bits). The last 8 bits (32 - 24 = 8) are filled 0's.
Now we have the binary version of the suffix.
Put dot (.) to separate each segment with 8 bits interval (dot-binary notation)./24
becomes11111111111111111111111100000000
, then11111111.11111111.11111111.00000000
- After that, do the
AND
operation for the binary version of the IPv4 and the binary version of the subnet mask.AND
OPERATIONS:
1AND
1 = 1
1AND
0 = 0
0AND
1 = 0
0AND
0 = 0
IP:11000000.10101000.00000000.00000001
Mask:11111111.11111111.11111111.00000000
--------------------------------------------------------------AND
RESULT:11000000.10101000.00000000.00000000
- Then convert the
AND
result back to dot-decimal notation. This is the first IP within the block. The HOST address.11000000.10101000.00000000.00000000
►192.168.0.0
- We now wanna get the last IP within the block. To do that, first convert the subnet mask dot-binary notation to dot-decimal notation.
11111111.11111111.11111111.00000000
►255.255.255.0
- Then, do subtraction like so:
FULL MASK:
255.255.255.255
SUBNET MASK:255.255.255. 0
----------------------------
SUBTRACTION RESULT:0. 0. 0.255
Or, you could invert the subnet mask binary version, then convert it back to decimal.
11111111.11111111.11111111.00000000
inverted becomes00000000.00000000.00000000.11111111
00000000.00000000.00000000.11111111
to decimal is0.0.0.255
.
Same result. -
The last IP then is calculated by adding the subtraction result number 6 above with the first IP we got from step number 4.
STARTING IP:
192.168. 0. 0
SUBTRACTION RESULT:0. 0. 0.255
---------------------------+
LAST IP:192.168. 0.255
-
COMPLETE.
So then192.168.0.1/24
is to tell the computer that its network HOST is at192.168.0.0
(and the network block is within192.168.0.0
—192.168.0.255
).
That's the main idea for translating the /number
suffix (network block) in IPv4 CIDR notation. It's not limited to this method, there are others, but the principles are like those above.