I'm struggling to understand how to compute the CIDR number from an IP address for hours. Examples I've seen don't explain how the provided answer was found. For example, if I have the IP 197.18.0.0, I thought the CIDR number was 24 because 197.18.0.0 is a class C address with a subnet mask of 255.255.255.0 so the first 24 bits would be 1s. Is this answer correct? If not, please explain how to find the CIDR number in this case. Thanks.
1 Answer
Network classes were deprecated in 1993 by RFCs 1517, 1518, and 1519, which defined CIDR. Modern networking does not use network classes.
The CIDR number is simply the number of one bits in the network mask. You cannot get a CIDR number from an address, it comes from the network mask.
You have no idea what the number is for your example of 197.18.0.0
, but if you had the mask 255.255.255.192
, you would know that it is 26
. So, 197.18.0.0
with a mask of 255.255.255.192
would be 197.18.0.0/26
.
-
-
Yes. You can have any mask length from
0
to32
on any network address. Basically you are saying thatX
number of address bits comprise the network number, and32-X
number of bits are the host number within that network. See the excellent answer to this question. You must do IP math in binary, otherwise you will make mistakes.– Ron Maupin ♦Dec 9, 2017 at 22:42 -
One more quick question. Based on my understanding of your answer, if I had the mask
255.255.255.0
, then the CIDR notation would be24
? Thanks. Dec 9, 2017 at 22:47 -
That is correct.
255.255.255.0
is11111111.11111111.11111111.00000000
in binary. If you count the number of one bits, it totals24
. The one bits are the network, and the zero bits are the host.– Ron Maupin ♦Dec 9, 2017 at 23:08