Troubleshooters.Com® and Linux Library Present:
CIDR Network Calculator
Copyright © 2018 by Steve Litt
See the Troubleshooters.Com Bookstore.
CONTENTS
This page hosts a CIDR Network Calculator that you can download and run on any computer with Python version 3.x. CIDR stands for "Classless Inter-Domain Routing", and represents the preferred method of carving up IPV4 networks for the last 15 years. You can view or download the calculator here.
To use this calculator to find a small IP address group containing addresses between 192.168.47.21 and 192.168.47.67, issue the following command:
[slitt@mydesk ~]$ ./cidr_calc.py 192.168.47.21/24
Original ip spec : 192.168.47.21/24
CIDR Network Notation : 192.168.47.0/24
Netmask : 255.255.255.0
IP range : 192.168.47.0 - 192.168.47.255
Chunk size : 256 (2^8) consecutive IPs
[slitt@mydesk ~]$
The /24 at the end was too inclusive, so trial and error /26 instead:
[slitt@mydesk ~]$ ./cidr_calc.py 192.168.47.21/26
Original ip spec : 192.168.47.21/26
CIDR Network Notation : 192.168.47.0/26
Netmask : 255.255.255.192
IP range : 192.168.47.0 - 192.168.47.63
Chunk size : 64 (2^6) consecutive IPs
[slitt@mydesk ~]$
Whoops, that's not inclusive enough because it stops short of 67. So split the difference:
[slitt@mydesk ~]$ ./cidr_calc.py 192.168.47.21/25
Original ip spec : 192.168.47.21/25
CIDR Network Notation : 192.168.47.0/25
Netmask : 255.255.255.128
IP range : 192.168.47.0 - 192.168.47.127
Chunk size : 128 (2^7) consecutive IPs
[slitt@mydesk ~]$
This calculator was deliberately made to be easily used with trial and error, so you can get the range you want to get.
Once again, you can view or download the calculator at http://troubleshooters.com/linux/cidr_calc.py.txt.
This calculator was built from the ground up for trial and error and "what if" usage. It was made assuming you have a "history" command so you can recall the preceding command with the uparrow key and modify the preceding command as needed. So start with the bottom-most IP address you want to cover, and keep adjusting the maskbits figure (the number after the slash), until you cover all the IP addresses you want..
This calculator isn't a spreadsheet. You can't modify any given variable and see all the rest change. The only variables you can modify are the IP address and the mask bits. The calculator then prints out all the rest of the information. The ip_address/maskbits format for the argument is used because it's simple and memorable.
If you have Python 3.x installed on your computer, whether Linux, BSD, Mac or Windows, you should be able to operate this calculator with the following command (in a terminal or command processor):
python3 ./cidr_calc.py 10.10.0.0/20
Obviously, substitute what you need for 10.10.0.0/20. If the command python3 doesn't run Python, version 3, for you, then find the command that does. You must have Python 3.x for this program to work: Python 2.x is deprecated and will cease all support 1/1/2020: 15 months from when this web page was first authored.
[ Training | Troubleshooters.Com | Email Steve Litt ]