About this calculator
The size of an IPv4 subnet can be written two ways. CIDR notation gives the number of leading 1-bits in the mask, such as /26. The dotted subnet mask writes the same 32 bits as four numbers, such as 255.255.255.192. Devices and routers may ask for either; this converter turns one into the other and checks that a mask is valid.
Formula
mask = 32 bits: n ones followed by (32 − n) zeros
Addresses = 2(32 − n) Wildcard = 255.255.255.255 − mask (bit by bit)
Valid masks have all their 1-bits together on the left. Each octet of a valid mask is one of 0, 128, 192, 224, 240, 248, 252, 254 or 255, and once an octet is below 255 all later octets are 0.
Worked example
- /26 = 11111111.11111111.11111111.11000000 = 255.255.255.192; 6 host bits, 64 addresses, 62 usable.
- 255.255.240.0 = /20; 12 host bits, 4096 addresses, wildcard 0.0.15.255.
- 255.0.255.0 is rejected: its 1-bits are not continuous.
Assumptions and limitations
- IPv4 only. Usable-host counts follow the usual convention (network and broadcast reserved), with /31 and /32 as special cases.
- This is a calculator only; it does not read or change any network settings.
References
- IETF RFC 4632 (Classless Inter-domain Routing, prefix notation); RFC 950 (subnet masks); RFC 3021 (/31).
