What CIDR notation is and why you need it
CIDR (Classless Inter-Domain Routing) notation is a way of writing an IP address and its network size in a single line. It looks like this: 192.168.1.0/24. The number after the slash tells you how many bits of the address belong to the network, and the rest belong to individual devices on that network. You need it because routers, firewalls, and network configuration tools expect this format when you're setting up subnets, access rules, or routing tables.
The CIDR number (called the prefix length) ranges from /0 to /32 for IPv4 addresses. A /24 network is common for small office or home networks and covers 256 addresses. A /32 is a single address. A /8 is enormous — it covers over 16 million addresses. The larger the number after the slash, the smaller the network.
Key Takeaways
- CIDR notation combines an IP address with a prefix length (the number after the slash) that defines how many addresses belong to that network.
- You can calculate CIDR from a subnet mask by counting the number of 1s in the binary version of the mask, or use an online CIDR calculator to convert instantly.
- Common CIDR ranges are /24 for small networks (256 addresses), /16 for medium networks (65,536 addresses), and /8 for large networks (16+ million addresses).
- Network calculators and command-line tools like ipcalc or sipcalc will show you the CIDR notation, broadcast address, and usable host range for any address you enter.
Converting a subnet mask to CIDR notation
If you have a subnet mask like 255.255.255.0, you can convert it to CIDR by counting the number of 1s in its binary form. The subnet mask 255.255.255.0 breaks down as: 11111111.11111111.11111111.00000000 in binary. Count the 1s: that's 24 ones, so the CIDR notation is /24.
Here are the most common subnet masks and their CIDR equivalents:
| Subnet Mask | CIDR Notation | Number of Addresses |
|---|---|---|
| 255.255.255.0 | /24 | 256 |
| 255.255.255.128 | /25 | 128 |
| 255.255.255.192 | /26 | 64 |
| 255.255.0.0 | /16 | 65,536 |
| 255.0.0.0 | /8 | 16,777,216 |
If you're working with an unusual mask, convert each octet (the four numbers separated by dots) to binary, write them all together, and count the 1s from left to right until you hit a 0. That count is your CIDR prefix.
Using an online CIDR calculator
The fastest way to find CIDR notation is to use a web-based calculator. Sites like ipcalc.co, subnet-calculator.com, or mxtoolbox.com let you paste in an IP address and subnet mask, and they instantly show you the CIDR notation along with other useful information like the network address, broadcast address, and the range of usable host addresses.
Type your IP address into the calculator (for example, 192.168.1.50) and either enter your subnet mask or select it from a dropdown. The calculator will display the CIDR notation immediately. Most calculators also show you how many addresses are in that network and which ones are reserved for the network and broadcast.
Finding CIDR from your device's network settings
On Windows, open Command Prompt and type ipconfig /all. Look for the line labeled "Subnet Mask" next to your IP address. Write down both numbers, then use the conversion table above or a calculator to find the CIDR notation.
On macOS or Linux, open Terminal and type ifconfig (macOS) or ip addr (Linux). The output will sometimes show CIDR notation directly — it looks like "inet 192.168.1.50/24". If it shows a subnet mask instead, convert it using the method above.
On network equipment like routers or switches, log into the admin interface and navigate to the network settings or LAN configuration page. The CIDR notation or subnet mask will be listed there. If only the mask is shown, convert it to CIDR using the table or a calculator.
Using command-line tools to calculate CIDR
If you prefer working in a terminal, the tool ipcalc is available on most Linux systems and macOS (via Homebrew). Type ipcalc 192.168.1.50 255.255.255.0 and it will output the CIDR notation along with network details. On Windows, you can install ipcalc through Windows Subsystem for Linux or use sipcalc, which works similarly.
Another option is nmap, a network scanning tool that understands CIDR notation. If you already have nmap installed, you can use it to verify CIDR ranges, though it's overkill if you just need a conversion.
Understanding what the CIDR number means
The number after the slash in CIDR notation represents how many bits of the 32-bit IPv4 address are used for the network portion. A /24 means the first 24 bits identify the network, and the remaining 8 bits identify individual hosts on that network. That's why /24 networks always have 256 addresses (2 to the power of 8).
Here's how the math works: /25 gives you 7 bits for hosts (2^7 = 128 addresses), /26 gives you 6 bits (2^6 = 64 addresses), and /30 gives you 2 bits (2^2 = 4 addresses). The larger the CIDR number, the smaller the network. This matters when you're dividing a large network into smaller subnets or when you're setting firewall rules that need to cover a specific range.
Common CIDR ranges and what they're used for
/32 is a single IP address — used when you need to allow or block one specific device. /30 is four addresses — common for point-to-point links like router-to-router connections. /24 is 256 addresses — the standard for small office or home networks. /16 is 65,536 addresses — used for medium-sized organizations. /8 is over 16 million addresses — used by large ISPs and enterprises.
Private networks (the ones you use inside your office or home) typically use /24 for the main network and then divide it further with larger CIDR numbers if they need separate subnets. Public networks assigned by your ISP might be /30, /29, or /28 depending on how many public addresses you need.
Frequently Asked Questions
What's the difference between /24 and 255.255.255.0?
They describe the same network size — /24 is just the shorthand CIDR notation for the subnet mask 255.255.255.0. Both mean the network uses 24 bits for the network address and 8 bits for individual devices, giving you 256 total addresses.
Can I use CIDR notation with IPv6 addresses?
Yes. IPv6 uses the same CIDR notation format, but the prefix can range from /0 to /128 instead of /32. An IPv6 address like 2001:db8::/32 means the first 32 bits identify the network. IPv6 calculators work the same way as IPv4 ones.
How do I know what CIDR to use when setting up a new network?
For a small office or home network, /24 is the standard choice — it gives you 254 usable addresses (256 minus the network and broadcast addresses). For larger networks, use /16 or /22. Your network administrator or ISP can recommend the right size based on how many devices you need to connect.
What does 0.0.0.0/0 mean?
This CIDR notation means "all IPv4 addresses" — every possible address on the internet. You'll see it in firewall rules when someone wants to allow or block traffic from anywhere. It's equivalent to a subnet mask of 0.0.0.0.
Can I convert CIDR back to a subnet mask?
Yes. Count the CIDR number — that's how many 1s go in the binary subnet mask from left to right. The rest are 0s. For /24, that's 24 ones followed by 8 zeros: 11111111.11111111.11111111.00000000, which converts to 255.255.255.0. Online calculators do this instantly in both directions.