Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why is the IPv4 ToCIDR method dividing an IP segment into multiple groups, such as 124.55.21.1--124.55.21.255. #28

Closed
BadDeveloper2022 opened this issue Apr 7, 2024 · 1 comment

Comments

@BadDeveloper2022
Copy link

Why is the IPv4 ToCIDR method dividing an IP segment into multiple groups, such as 124.55.21.1--124.55.21.255.
But 124.55.21.0-124.55.21.255 only grouped one.
In theory, 124.55.21.1-124.55.21.255 can be divided into two parts, right
124.55.21.1--124.55.21.127
124.55.21.128--124.55.21.255

@ip2location
Copy link
Owner

I try my best to explain the calculation about the CIDR calculation. The IP address contains 4 octets, and each of them are 8 bits that give values between 0 and 255. The number that comes after the slash is the number of bits consisting of the routing prefix. This can be calculated as netmask, and also determine how many available addresses are in the block.

If the routing prefix value is less than 31, first and last IPs are base and broadcast addresses and are unusable.

For the group you suggested (124.55.21.1 - 124.55.21.227), where the CIDR base IP is on 124.55.21.0, the closest group you can get is 124.55.21.1/25. Its first useable IP is 124.55.21.1 and last usable IP is 124.55.21.126 (Not 124.55.21.127).

You can cross-check the result with ARIN, and Wikipedia.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants