CIDR to Netmask Converter
Enter a CIDR prefix like 24 or a netmask, then pick the direction.
Result
How it is calculated
In the prefix-to-mask direction the tool sets the first p bits of a 32-bit number to 1 and writes the result as four decimal octets. The wildcard mask is the same number with every bit flipped. The host count is 232−p − 2, because the first address of the block is the network address and the last is the broadcast address. Two special cases follow RFC 3021: a /31 is shown as 2 usable hosts (a point-to-point link) and a /32 as 1 host. The prefix may be typed with or without a leading slash and must be 0 to 32. In the mask-to-prefix direction the four octets are turned into bits and counted; the mask must be four numbers from 0 to 255 whose bits are all 1s followed by all 0s, otherwise nothing is returned. This covers IPv4 only.
Worked example
Take prefix 26 in the prefix-to-mask direction. 26 ones followed by 6 zeros gives 11111111.11111111.11111111.11000000, which is 255.255.255.192, shown as 255.255.255.192. The wildcard is the inverse: 0.0.0.63. Host bits = 32 − 26 = 6, so 26 − 2 = 64 − 2 = 62 usable hosts. The tool reports 62 usable hosts.
Common mistakes
- Typing a mask while the direction is set to prefix-to-mask. Entering 255.255.255.0 there gives no result; switch the direction to mask-to-prefix first.
- Typing a prefix in the mask-to-prefix direction. A plain number like 24 is not a dotted mask and gives no result.
- Entering a non-contiguous mask such as 255.0.255.0. Subnet masks must be ones followed by zeros, so this is rejected, and a prefix above 32 is rejected too.
- Reading the wildcard mask as another subnet mask. It is the bitwise inverse (0.0.0.63 for /26), the form used in access lists, not a mask you assign to an interface.
- Assuming every subnet loses two addresses. A /31 lists 2 usable hosts and a /32 lists 1, because those prefixes have special rules, whereas a /30 gives 2 and a /26 gives 62.
About this calculator
CIDR notation (Classless Inter-Domain Routing) expresses an IPv4 subnet mask as a prefix length — the number of leading 1-bits in the 32-bit mask — written after a slash, such as /24. A /24 prefix means the first 24 bits are network bits and the remaining 8 are host bits, which translates to the dotted-decimal mask 255.255.255.0; converting in the other direction, a dotted mask is read bit by bit to recover its prefix length. The number of usable host addresses in a subnet is 2^(32−prefix) − 2, subtracting the network address and broadcast address that can’t be assigned to a host.
The wildcard mask — the bitwise inverse of the subnet mask — is used separately in access control lists and routing configurations (notably on Cisco IOS) where matching rules are expressed as “don’t care” bits rather than network/host bits. Network engineers and system administrators move between prefix length, dotted-decimal mask, host count, and wildcard mask constantly when planning subnets, writing firewall rules, or configuring routers; this calculator converts a CIDR prefix (or a netmask) into all of these related values.
Was this helpful?
You can pick up to 3 reactions.
Popular calculators
Loan Calculator
Monthly payment, total interest and full amortization schedule.
Percentage Calculator
Percent change, percent of, and ratio calculations.
Discount Calculator
Calculate final price, savings, and discount amount.
BMI Calculator
Body mass index from height and weight (metric or imperial).
Age Calculator
Compute your exact age in years, months and days from a birth date.
Compound Interest Calculator
Calculate the final amount and interest earned with compounding.
All Calculators
- Loan Calculator
- Profit Calculator
- Discount Calculator
- BMI Calculator
- Percentage Calculator
- Ideal Weight Calculator
- Age Calculator
- Pregnancy Due Date Calculator
- Compound Interest Calculator
- BMR Calculator (Basal Metabolic Rate)
- Tip Calculator
- Fuel Cost Calculator
- Date Difference Calculator
- Sleep Cycle Calculator
- Daily Water Intake Calculator
- Simple Interest Calculator
- Heart Rate Zones Calculator
- Running Pace Calculator
- Pet Age Calculator
- Calories Burned Calculator
- Macro Calculator
- TDEE Calculator (Total Daily Energy Expenditure)
- Waist-to-Hip Ratio Calculator
- Honor Roll Calculator
- One Rep Max (1RM) Calculator
- Ovulation Calculator
- Electricity Cost Calculator
- Unit Price Calculator
- Savings Goal Calculator
- Break-Even Point Calculator
- Paint Calculator
- Course Grade Average Calculator
- Business Days Calculator
- Time Duration Calculator
- Fuel Economy Calculator
- Temperature Converter
- Tile Calculator
- Aspect Ratio Calculator
- Roman Numeral Converter
- Goal Weight Timeline Calculator
- Salary Converter (Hourly to Annual)
- Credit Card Validator (Luhn)
- Body Surface Area (BSA) Calculator
- Feels-Like Temperature Calculator
- Ohm’s Law Calculator
- PPI (Pixel Density) Calculator
- Molar Mass Calculator
- Zodiac Sign Calculator (Western + Chinese)
- IBAN Validator
- Shoe Size Converter
- Country Info & Dialing Code Lookup
- Time Zone Difference (World Clock)
- CAGR (Compound Annual Growth Rate) Calculator
- Rule of 72 Calculator
- Blood Alcohol Content (BAC) Calculator
- Lean Body Mass (LBM) Calculator
- Pythagorean Theorem Calculator
- Speed Converter
- Download Time Calculator
- Date Calculator (Add/Subtract)
No calculators found
Comments (1)
The wildcard line is the one you paste into Cisco-style access lists and OSPF network statements, where the mask is written inverted. And on router-to-router links, the /31 result of 2 usable hosts follows RFC 3021, which saves addresses compared with /30, though some older gear may not accept it. Would you like IPv6 prefixes added as well?