Code
Talk is cheap. Show me the code.
Subnet Details
About this tool
How subnet masks and CIDR work
An IPv4 address has 32 bits. A subnet mask says how many of those bits identify the network and how many identify hosts on it. CIDR notation writes that as a prefix length: 192.168.1.0/24 means the first 24 bits are the network, so the mask is 255.255.255.0 and 8 bits are left for hosts.
Usable hosts on a subnet = 2(32 − prefix) − 2. The two addresses taken out are the network address (all host bits 0) and the broadcast address (all host bits 1). The exceptions are /31, which is used for point-to-point links (RFC 3021), and /32, which is a single host.
Common prefix lengths
| CIDR | Netmask | Usable hosts |
|---|---|---|
| /24 | 255.255.255.0 | 254 |
| /25 | 255.255.255.128 | 126 |
| /26 | 255.255.255.192 | 62 |
| /27 | 255.255.255.224 | 30 |
| /28 | 255.255.255.240 | 14 |
| /29 | 255.255.255.248 | 6 |
| /30 | 255.255.255.252 | 2 |
| /31 | 255.255.255.254 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 (single host) |
FAQ
How many hosts are in a /27? A /27 has 32 addresses and 30 usable hosts.
What is a wildcard mask? It is the inverse of the subnet mask (for /24, 0.0.0.255). Access lists and OSPF network statements on many routers use it.
What are private IPv4 ranges? 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918).