Subnet Mask and Prefix Converter
Convert between /24 and 255.255.255.0, in either direction, with the whole table.
Drag, or type a mask on the right.
Equivalent to /24.
/24 is
255.255.255.0
24 network bits, 8 host bits — 256 addresses, 254 usable for hosts.
11111111.11111111.11111111.00000000
Prefix
/24
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
The inverse. What Cisco ACLs expect.
Total addresses
256
Usable hosts
254
Two fewer than the total — the network and broadcast addresses.
Blocks in a /24
1
Every prefix
The current selection is highlighted. Note the fourth-octet masks — 128, 192, 224, 240, 248, 252, 254, 255 — those eight values are the only legal ones in any octet, which is what makes an invalid mask easy to spot by eye.
| Prefix | Mask | Wildcard | Addresses | Usable |
|---|---|---|---|---|
| /0 | 0.0.0.0 | 255.255.255.255 | 4,294,967,296 | 4,294,967,294 |
| /1 | 128.0.0.0 | 127.255.255.255 | 2,147,483,648 | 2,147,483,646 |
| /2 | 192.0.0.0 | 63.255.255.255 | 1,073,741,824 | 1,073,741,822 |
| /3 | 224.0.0.0 | 31.255.255.255 | 536,870,912 | 536,870,910 |
| /4 | 240.0.0.0 | 15.255.255.255 | 268,435,456 | 268,435,454 |
| /5 | 248.0.0.0 | 7.255.255.255 | 134,217,728 | 134,217,726 |
| /6 | 252.0.0.0 | 3.255.255.255 | 67,108,864 | 67,108,862 |
| /7 | 254.0.0.0 | 1.255.255.255 | 33,554,432 | 33,554,430 |
| /8 | 255.0.0.0 | 0.255.255.255 | 16,777,216 | 16,777,214 |
| /9 | 255.128.0.0 | 0.127.255.255 | 8,388,608 | 8,388,606 |
| /10 | 255.192.0.0 | 0.63.255.255 | 4,194,304 | 4,194,302 |
| /11 | 255.224.0.0 | 0.31.255.255 | 2,097,152 | 2,097,150 |
| /12 | 255.240.0.0 | 0.15.255.255 | 1,048,576 | 1,048,574 |
| /13 | 255.248.0.0 | 0.7.255.255 | 524,288 | 524,286 |
| /14 | 255.252.0.0 | 0.3.255.255 | 262,144 | 262,142 |
| /15 | 255.254.0.0 | 0.1.255.255 | 131,072 | 131,070 |
| /16 | 255.255.0.0 | 0.0.255.255 | 65,536 | 65,534 |
| /17 | 255.255.128.0 | 0.0.127.255 | 32,768 | 32,766 |
| /18 | 255.255.192.0 | 0.0.63.255 | 16,384 | 16,382 |
| /19 | 255.255.224.0 | 0.0.31.255 | 8,192 | 8,190 |
| /20 | 255.255.240.0 | 0.0.15.255 | 4,096 | 4,094 |
| /21 | 255.255.248.0 | 0.0.7.255 | 2,048 | 2,046 |
| /22 | 255.255.252.0 | 0.0.3.255 | 1,024 | 1,022 |
| /23 | 255.255.254.0 | 0.0.1.255 | 512 | 510 |
| /24 | 255.255.255.0 | 0.0.0.255 | 256 | 254 |
| /25 | 255.255.255.128 | 0.0.0.127 | 128 | 126 |
| /26 | 255.255.255.192 | 0.0.0.63 | 64 | 62 |
| /27 | 255.255.255.224 | 0.0.0.31 | 32 | 30 |
| /28 | 255.255.255.240 | 0.0.0.15 | 16 | 14 |
| /29 | 255.255.255.248 | 0.0.0.7 | 8 | 6 |
| /30 | 255.255.255.252 | 0.0.0.3 | 4 | 2 |
| /31 | 255.255.255.254 | 0.0.0.1 | 2 | 2 |
| /32 | 255.255.255.255 | 0.0.0.0 | 1 | 1 |
Two notations, one set of bits
A subnet mask and a prefix length say exactly the same thing in different alphabets. Both describe how many of an address’s thirty-two bits are fixed by the network.
The mask says it as thirty-two bits written in dotted decimal, with ones for the network part and zeros for the host part. 255.255.255.0 is twenty-four ones followed by eight zeros. The prefix just states the count: /24. Same bits, fewer characters.
Prefix notation won, and every modern tool uses it. Dotted-decimal masks persist because Cisco IOS interface configuration, Windows network settings and a great deal of existing documentation are written that way — which is why this conversion keeps coming up years after the notation was superseded.
Why only nine numbers are legal in an octet
The ones in a mask must be contiguous from the left. Within a single octet that permits nine values and no others:
| Bits set | Binary | Decimal |
|---|---|---|
| 0 | 00000000 | 0 |
| 1 | 10000000 | 128 |
| 2 | 11000000 | 192 |
| 3 | 11100000 | 224 |
| 4 | 11110000 | 240 |
| 5 | 11111000 | 248 |
| 6 | 11111100 | 252 |
| 7 | 11111110 | 254 |
| 8 | 11111111 | 255 |
Memorising that column is most of what “being good at subnetting by hand” amounts to. It also gives you a fast validity check by eye: any octet in a mask that is not one of those nine numbers is wrong, and any octet after a non-255 one must be 0.
The three masks that come up constantly
255.255.255.0 (/24) is the default on essentially every consumer router. 255.255.255.252 (/30) was the traditional point-to-point link mask — four addresses, two usable — now largely replaced by 255.255.255.254 (/31), which gives both addresses to hosts. And 255.255.0.0 (/16) is what Windows offers when it guesses, which is usually far larger than anyone wanted.
Doing it in your head
The trick is that only one octet is ever interesting. Everything to its left is 255, everything to its right is 0, and the prefix tells you which one and how far into it.
Divide the prefix by 8. The quotient is how many 255s; the remainder is how many bits are set in the next octet. For /26: 26 ÷ 8 is 3 remainder 2, so three 255s and then two bits — which the table above says is 192. 255.255.255.192.
Block size falls out of the same remainder: 256 minus the interesting octet. 256 − 192 = 64, so /26 blocks are 64 addresses and start at .0, .64, .128 and .192.
Related
To apply a mask to an actual address and get the network, broadcast and host range, the subnet calculator does the whole breakdown. To convert between blocks and address ranges in either direction, use the CIDR calculator.
Mask questions
What is 255.255.255.0?
A /24. It fixes the first twenty-four bits — the first three octets — and leaves the last eight free, giving 256 addresses of which 254 are usable. It is the default on almost every home router and the most common mask in existence.
Why can a mask only contain 0, 128, 192, 224, 240, 248, 252, 254 and 255?
Because the ones in a subnet mask have to run unbroken from the left. Within any octet that leaves exactly nine possibilities: no bits set, then one, then two, and so on up to all eight. Written in decimal those are 0, 128, 192, 224, 240, 248, 252, 254 and 255. Anything else — 255.255.0.255, or a 100 in any octet — has a gap in the run and is not a valid mask. The converter above rejects those rather than guessing what you meant.
Is 255.255.255.0 the same as /24 in every context?
For subnet masks, yes — they are two notations for the same thirty-two bits. Where they differ is what accepts them: Cisco IOS interface commands want dotted decimal, Linux ip commands and most cloud consoles want the prefix, and access control lists want the wildcard form instead. That is the entire reason this conversion comes up so often.
What is the wildcard mask for?
It is the subnet mask inverted, so /24 becomes 0.0.0.255. Cisco access control lists and OSPF network statements expect it in that form. It exists as a separate concept because a wildcard mask does not have to be contiguous — you can express "match any address whose last octet is even" — though in practice nearly every one you write is simply an inverted subnet mask.
Which mask do I need for 50 devices?
A /26, which is 255.255.255.192. It gives 64 addresses and 62 usable ones after the network and broadcast addresses are set aside. A /27 would give only 30 usable and would not fit. Leave the headroom: renumbering a network that filled up is considerably more painful than allocating the next size up.
Last reviewed . Found something out of date? Tell us.
