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 184.108.40.206, I thought the CIDR number was 24 because 220.127.116.11 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.
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
18.104.22.168, but if you had the mask
255.255.255.192, you would know that it is
22.214.171.124 with a mask of
255.255.255.192 would be
So, the mask
255.255.255.192was arbitrarily chosen? Dec 9, 2017 at 22:38
Yes. You can have any mask length from
32on any network address. Basically you are saying that
Xnumber of address bits comprise the network number, and
32-Xnumber 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 be
24? Thanks. Dec 9, 2017 at 22:47
That is correct.
11111111.11111111.11111111.00000000in binary. If you count the number of one bits, it totals
24. The one bits are the network, and the zero bits are the host.– Ron Maupin ♦Dec 9, 2017 at 23:08