On this page
How to use the subnet calculator
- IPv4: type an address with its prefix, such as
192.168.10.37/26. The answer updates as you type. - Open Show the binary working under the result. It lines up the address, the mask, the AND result and the broadcast bit by bit, with network bits in green and host bits in orange.
- Split and summarize: split a network by number of subnets, new prefix or hosts per subnet, or paste a list of routes to summarize.
- VLSM: enter a base network and one row per subnet with the hosts it needs. The planner places the largest block first.
- IPv6: type an address with its prefix length, such as
2001:db8:abcd:12::1/64, and choose a longer prefix to split it. - Practice: press New question, fill in the five boxes and press Check my answers.
| You type | Read as |
|---|---|
192.168.10.37/26 | Prefix length 26 |
192.168.10.37 255.255.255.192 | Subnet mask, so /26 |
192.168.10.37 0.0.0.63 | Wildcard mask, so /26 |
192.168.10.37 | Uses the Prefix menu |
2001:db8::1/64 | IPv6 prefix; with no prefix, /64 is used |
Every result has a Copy link button, and links like these open the exact problem:
| Add to the page address | Opens |
|---|---|
?ip=10.0.0.0/22 | The IPv4 result for 10.0.0.0/22 |
?tab=split&net=192.168.0.0/24&by=subnets&n=6 | A split (by is subnets, prefix or hosts) |
?tab=split&nets=10.1.0.0/24,10.1.1.0/24 | A route summary |
?tab=vlsm&net=192.168.1.0/24&hosts=50,20,10 | A VLSM plan (add &names=Sales,HR,Lab) |
?ip=2001:db8::/48&split=64 | An IPv6 prefix split into /64s |
?tab=practice&q=172.16.45.200/21 | One practice question |
How subnetting works in binary
An IPv4 address is 32 bits, written as four 8-bit numbers called octets. The prefix length /p says how many bits from the left name the network. The other 32 − p bits number the hosts inside it. The subnet mask writes the same thing as an address: p ones, then zeros, so /26 is 255.255.255.192. The wildcard mask flips every bit (0.0.0.63) and is what Cisco ACLs and OSPF network statements use.
- Network address = address AND mask: keep the network bits, set the host bits to 0.
- Broadcast address = the network address with every host bit set to 1.
- Total addresses = 2^(32 − p). Usable hosts = 2^(32 − p) − 2.
- First host = network + 1. Last host = broadcast − 1.
The "minus 2" removes the network address and the broadcast address, which no host can use.
| Prefix | Mask | Addresses | Usable hosts |
|---|---|---|---|
| /16 | 255.255.0.0 | 65,536 | 65,534 |
| /22 | 255.255.252.0 | 1,024 | 1,022 |
| /24 | 255.255.255.0 | 256 | 254 |
| /25 | 255.255.255.128 | 128 | 126 |
| /26 | 255.255.255.192 | 64 | 62 |
| /27 | 255.255.255.224 | 32 | 30 |
| /28 | 255.255.255.240 | 16 | 14 |
| /29 | 255.255.255.248 | 8 | 6 |
| /30 | 255.255.255.252 | 4 | 2 |
| /31 | 255.255.255.254 | 2 | 2 (point-to-point) |
| /32 | 255.255.255.255 | 1 | 1 (single host) |
The magic-number shortcut
You rarely need all 32 bits. Find the interesting octet, the one where the mask is neither 255 nor 0. The block size is 256 minus that mask octet, and subnets start at multiples of it. The network is the last multiple at or below the address's octet; the broadcast is one less than the next multiple. For the mask 255.255.255.224 the block is 256 − 224 = 32, so subnets start at 0, 32, 64, 96 and so on.
/31 and /32
A /31 has only two addresses. Under RFC 3021 both are usable on a point-to-point link between two routers, because such a link needs no broadcast. A /32 is one address, used for loopbacks and host routes. The calculator reports 2 and 1 usable hosts for them, not the 0 and −1 the formula would give.
Route summarization
To summarize routes, write the networks in binary and count the leading bits they all share. 172.16.4.0/24, 172.16.5.0/24 and 172.16.6.0/24 differ only in the third octet, where 00000100, 00000101 and 00000110 share their first 6 bits. The summary keeps 16 + 6 = 22 bits: 172.16.4.0/22. That route also covers 172.16.7.0/24, which was not listed, so the tool flags 256 extra addresses and gives the exact alternative, 172.16.4.0/23 plus 172.16.6.0/24.
Three worked examples
1. 192.168.10.37/26, bit by bit
A /26 leaves 6 host bits. Line up the address and the mask; the bar marks where the network bits end:
| Line | Dotted | Binary |
|---|---|---|
| Address | 192.168.10.37 | 11000000.10101000.00001010.00|100101 |
| Mask /26 | 255.255.255.192 | 11111111.11111111.11111111.11|000000 |
| AND = network | 192.168.10.0 | 11000000.10101000.00001010.00|000000 |
| Host bits 1 = broadcast | 192.168.10.63 | 11000000.10101000.00001010.00|111111 |
The hosts run from 192.168.10.1 to 192.168.10.62, so 2^6 − 2 = 62 are usable. The shortcut agrees: the block size is 256 − 192 = 64, and 37 sits in the block 0 to 63.
2. 172.16.45.200/21 with the magic number
This one catches many CCNA students, because the prefix ends in the third octet. The mask is 255.255.248.0, so the third octet is the interesting one and the block size is 256 − 248 = 8. Blocks start at 0, 8, 16, 24, 32, 40, 48 and so on, and 45 falls in the block 40 to 47.
- Network: 172.16.40.0 (third octet 40, last octet 0)
- Broadcast: 172.16.47.255 (third octet 47, last octet 255)
- Hosts: 172.16.40.1 to 172.16.47.254, which is 2^11 − 2 = 2,046
In binary, 45 is 00101101 and 248 is 11111000. Their AND is 00101000, which is 40, the same answer.
3. VLSM for four departments
A branch office gets 192.168.1.0/24 and needs four subnets: Sales with 50 hosts, HR with 20, a lab with 10 and a WAN link with 2. For each, add 2 for the network and broadcast addresses and round up to a power of two: 52 becomes 64 (/26), 22 becomes 32 (/27), 12 becomes 16 (/28) and 4 stays 4 (/30). Then place them largest first:
| Subnet | Hosts needed | Network | Usable range | Broadcast | Wasted |
|---|---|---|---|---|---|
| Sales | 50 | 192.168.1.0/26 | .1 to .62 | .63 | 12 |
| HR | 20 | 192.168.1.64/27 | .65 to .94 | .95 | 10 |
| Lab | 10 | 192.168.1.96/28 | .97 to .110 | .111 | 4 |
| WAN link | 2 | 192.168.1.112/30 | .113 to .114 | .115 | 0 |
The plan uses 116 of the 256 addresses. The rest, 192.168.1.116/30, 192.168.1.120/29 and 192.168.1.128/25, stays free for growth: 140 addresses in all.
IPv6 and the /64 rule
An IPv6 address is 128 bits, written as eight groups of four hex digits. RFC 5952 fixes the short form: drop leading zeros in each group, use lower case, and replace the longest run of two or more all-zero groups with ::, taking the first run when two tie. So 2001:0db8:0000:0000:0001:0000:0000:0001 is written 2001:db8::1:0:0:1.
The other rule is the /64. An IPv6 LAN is a /64 because SLAAC, the automatic addressing most devices use, builds the last 64 bits (the interface ID) on its own. One /64 holds 2^64 = 18,446,744,073,709,551,616 addresses, so you never size an IPv6 LAN by host count. You count /64s instead: a /48 site has 2^16 = 65,536 of them, and a /56 has 256. IPv6 has no broadcast address. Prefixes longer than /64 break SLAAC, so keep them for point-to-point links (/127) and loopbacks (/128).
Common subnetting mistakes
- Counting the network and broadcast as hosts. A /26 has 64 addresses but 62 usable hosts, and a /30 has 4 addresses but 2 hosts.
- Giving the typed address as the network. 192.168.10.37/26 is a host; its network is 192.168.10.0. The tool warns when you type the network or broadcast address itself.
- Borrowing too few bits. Six subnets need 3 borrowed bits, because 2^2 = 4 is too few. Splitting a /24 that way gives 8 subnets of /27 with 30 hosts each.
- Impossible masks. Each mask octet is 0, 128, 192, 224, 240, 248, 252, 254 or 255, and the 1 bits come first. 255.0.255.0 is not a mask.
- VLSM in the wrong order. Placing a small subnet first can push a large one off its boundary, which leaves gaps or overlaps. Go largest first.
- Trusting the class. 172.16.45.200 is a class B address, but that says nothing about its mask today. CIDR replaced classes in 1993, so read the prefix.
- Mixing up mask and wildcard. The ACL entry
10.1.1.0 0.0.0.255means a /24. The calculator reads 0.0.0.255 as a wildcard, so it gives the same /24.
Learn the mask octets 128, 192, 224, 240, 248 and 252 with their block sizes 128, 64, 32, 16, 8 and 4. Most subnetting questions then come down to one subtraction from 256. Use the Practice tab until you get all five answers right without the binary.
Embed the Subnet Calculator on your website
Teachers, bloggers and course sites can add this tool to any web page for free. Paste the code below into an HTML or embed block (WordPress, Google Sites, Canvas, Moodle, Blogger, Wix). It loads the same tool you see above, without our menus or ads. Please keep the credit line under the frame. Sizes, a live preview and step-by-step guides for each platform are on the calculator widget page.
Frequently asked questions
How many usable hosts are in a /24?
254. A /24 has 2^8 = 256 addresses, and the network address and the broadcast address cannot be given to hosts, so 256 − 2 = 254 are usable. The same rule gives 62 for a /26 and 2 for a /30.
What is the difference between a subnet mask and a wildcard mask?
They are bitwise opposites. The subnet mask 255.255.255.0 has 1 bits for the network part, while the wildcard 0.0.0.255 has 1 bits for the part that may vary. Cisco ACLs and OSPF use wildcards. This calculator accepts either one and shows both.
Why does a /31 have two usable addresses?
RFC 3021 allows a /31 on a point-to-point link, where only two devices exist and no broadcast is needed. Both addresses go to the two routers, which uses half the addresses a /30 would. The calculator shows 2 usable hosts for a /31.
How do I work out how many subnets I get?
Each bit you borrow from the host part doubles the subnets: subnets = 2^(new prefix − old prefix). Going from /24 to /27 borrows 3 bits and gives 8 subnets of 32 addresses, with 30 usable hosts each. The Split tab works this out from a count, a prefix or a host requirement.
Are IP address classes still used?
Not for routing. Classes A, B and C gave fixed masks of /8, /16 and /24 until CIDR replaced them in 1993. Exams still ask for the class, so the calculator shows it, marked as historical.
How many /64 subnets are in a /48?
65,536, because 2^(64 − 48) = 2^16. A /56 holds 256 of them and a /60 holds 16. The IPv6 tab shows this count for any prefix and can list the /64s.