Subnet Calculator
Subnet calculator for IPv4: network and broadcast address, subnet mask, host count and splitting a /16 into subnets. Everything is computed in your browser.
Why a subnet calculator earns its keep
A subnet calculator earns its keep the moment a network is described in CIDR notation: 192.168.1.0/24 on a home router, 10.0.0.0/8 in a datacentre rack, 172.16.0.0/12 between two offices. In a minute it converts the address to binary, finds the subnet mask, the network and broadcast addresses, counts the usable host range and explains why only 254 of the 256 addresses in a /24 can be handed out to devices. A second mode answers the question behind "how many hosts does a /26 hold", and a third one shows how to turn a /16 into four /18 subnets with a table of ranges. Every calculation runs in the browser, so neither the address nor the prefix is sent anywhere.
What the subnet calculator does
- Accepts a network in CIDR notation (192.168.1.0/24) or an address and a prefix entered separately
- Shows the subnet mask, wildcard mask, network and broadcast addresses, first and last usable address
- Reports the total address count and the usable host count, and explains the two reserved addresses
- Adds the address class, the private or public verdict, and the binary form of both address and mask
- Has a mask mode that answers how many hosts a prefix holds, with a quick table of common prefixes
- Splits a network on demand: a /16 into four /18 subnets with ranges, masks and broadcast addresses
How to calculate a subnet
- Type the network in CIDR notation, or switch the input to a separate address and prefix
- Read the mask, the network and broadcast addresses, and the usable host range
- For a mask lookup, enter the prefix — /24 or /26, for instance
- For splitting, give the base network and either a subnet count or a new prefix
How the numbers are produced
The address becomes a 32-bit number and the mask comes from a shift: for /24 that is twenty-four ones followed by eight zeros, which is 255.255.255.0. A bitwise AND with the mask yields the network address, and OR with the inverted mask yields the broadcast address. The address count is two raised to the number of host bits, so a /24 holds 2 to the 8th power, that is 256 addresses, and two fewer are available to devices: 254. The first usable address is the network address plus one, the last is the broadcast address minus one. No request leaves the page, and the whole calculation takes a fraction of a millisecond.
Sample subnets and what the calculator reports
| Network | Mask and host range | Hosts |
|---|---|---|
| 192.168.1.0/24 | 255.255.255.0, 192.168.1.1 — 192.168.1.254 | 254 |
| 10.0.0.0/8 | 255.0.0.0, 10.0.0.1 — 10.255.255.254 | 16 777 214 |
| 172.16.0.0/12 | 255.240.0.0, 172.16.0.1 — 172.31.255.254 | 1 048 574 |
| 192.168.0.0/22 | 255.255.252.0, 192.168.0.1 — 192.168.3.254 | 1 022 |
| 192.168.1.0/26 | 255.255.255.192, 192.168.1.1 — 192.168.1.62 | 62 |
| 192.168.1.0/28 | 255.255.255.240, 192.168.1.1 — 192.168.1.14 | 14 |
| 10.0.0.0/9 | 255.128.0.0, 10.0.0.1 — 10.127.255.254 | 8 388 606 |
| 10.0.0.0/18 | 255.255.192.0, 10.0.0.1 — 10.0.63.254 | 16 382 |
| 172.16.0.0/20 | 255.255.240.0, 172.16.0.1 — 172.16.15.254 | 4 094 |
| 8.8.8.0/30 | 255.255.255.252, 8.8.8.1 — 8.8.8.2 | 2 |
The host count is always two below the total: the network and broadcast addresses never go to devices.
Where subnet maths shows up in real work
The first place subnet maths becomes part of daily work is the home network. A router hands out addresses from 192.168.1.0/24, and once a dozen devices are online the question becomes how to split that block: move cameras and guest phones into their own subnets so they do not swamp the main traffic. The second place is cloud infrastructure, where ordering a virtual machine shows a ready-made CIDR and asks you to pick a mask for extra network interfaces.
Engineering work brings the calculation back during incident review. A router log showing a packet addressed to the broadcast address 192.168.1.255 makes the first check simple: confirm that 192.168.1.0/24 is configured as intended and that the address really belongs to that subnet rather than to a neighbouring one that leaked into the routing table. The same habit catches planning errors: if a design document says 10.10.10.0/24 next to 10.10.0.0/16, one of the two was written on the wrong boundary. Pulling a host out of a log or a link is easier with a URL broken into parts, and the HTTP status code reference explains what the response line is telling you.
- Splitting a home router across subnets for different device types
- Ordering a cloud server with additional network interfaces
- Checking the address plan and router configuration
- Sizing an address pool for an office network
- Choosing a mask that fits the number of devices in a VLAN
- Reading addresses out of network equipment logs
Where subnet calculations go wrong
The first mistake is assuming a /24 holds some other number of addresses because the prefix looks like a class. Twenty-four network bits and eight host bits give exactly 256 addresses — there is no extra pair of addresses hiding behind the arithmetic of two to a power. The second mistake is swapping the network address for the broadcast address: in a /24 those are 192.168.1.0 and 192.168.1.255, with the host range sitting between them. The third, and most expensive one, is using a mask that does not exist inside the block.
Mask mistakes deserve their own paragraph, because the address looks right while the network misbehaves. In 192.168.1.0/24 and 192.168.1.128/25 the first 128 addresses coincide, so a router may happily accept traffic that was meant for a different subnet. Another subtlety: addresses from 127.0.0.0/8 only work on the device itself, and 169.254.0.0/16 appears on its own when an interface fails to get a DHCP lease, so neither should be counted as a working address.
- Confusing the number of network bits with the number of addresses
- Assigning the network or broadcast address to a device
- Using a mask that does not exist in the block, such as 255.255.255.192 in a /24
- Treating 127.0.0.0/8 as a working network when it only works locally
- Mistaking a 169.254.0.0/16 address for a normal DHCP lease
- Applying the minus-two rule to /31 and /32
A worked example: 192.168.1.0/24 step by step
Take the network 192.168.1.0/24 apart. The prefix 24 means the first 24 bits of the address describe the network and the remaining 8 bits describe the host. Eight free bits give 2 to the 8th power, that is 256 addresses in the block. Two of them are reserved, so 254 hosts remain and their working range is 192.168.1.1 to 192.168.1.254.
The same address is easier to verify in binary: 192 is 11000000 and 168 is 10101000, while the third and fourth octets carry the prefix and the host part. The mask 255.255.255.0 reads as 24 ones and eight zeros. ANDing the address with the mask drops the host part and leaves 192.168.1.0; inverting the mask gives 0.0.0.255, and adding it to the network address produces the broadcast 192.168.1.255. The binary view is what helps when a calculation has to be done by hand or a config needs checking, and a binary converter takes care of the octet-to-bits part.
What happens at each step
| Step | Action | Result |
|---|---|---|
| 1 | Parse the input | 192.168.1.0/24 splits into an address and a prefix |
| 2 | Build the mask | 24 ones and 8 zeros give 255.255.255.0 |
| 3 | Network address | AND with the mask leaves 192.168.1.0 |
| 4 | Invert the mask | 255.255.255.0 becomes 0.0.0.255 |
| 5 | Broadcast address | Network address OR the inverted mask: 192.168.1.255 |
| 6 | Address count | 8 host bits give 2 to the 8th power, 256 |
| 7 | Host count | Subtract the network and broadcast addresses: 254 |
| 8 | Usable range | First host 192.168.1.1, last host 192.168.1.254 |
Every step is a bitwise operation on a 32-bit number, so a /8 is calculated just as fast as a /32.
Subnets, masks and neighbouring tools
Subnet work rarely stands alone: you usually need to read the address itself or check a binary form alongside it. For a quick orientation there is an IP address checker that takes an address and immediately says whether it is private or public. When the idea of numbers in different bases feels shaky, the number base converter and the plain-language piece on binary code cover the two ideas the whole calculation rests on.
A frequent companion to subnets is an access rule, where networks are listed one after another. The .htaccess generator builds such lists, including blocks by address and by range, and shows what the finished Apache configuration looks like. Since those rules are written as regular expressions, they can be tested in advance with the regular expression tester.
- Checking an IP address and its class
- Converting numbers between binary, hexadecimal and other bases
- Understanding binary without a technical background
- Building address lists for access rules
- Testing the regular expressions used in access lists
- Sizing masks for routers and firewalls
Questions people ask about subnets
Why are only 254 of the 256 addresses in a /24 usable
How does /24 differ from the mask 255.255.255.0
Can I assign a public IP address to myself
What are address classes A, B and C
How do I split a /16 into four /18 subnets
What should I count for a /31 or a /32
Which ranges count as private
Why does a /8 hold so many addresses
Related articles
Subnet Calculator: How to Work Out Addresses, Masks and Ranges
How an IP address is put together, what a subnet mask and CIDR prefix mean, how many addresses fit in a network, where the broadcast address sits, and why private addresses must never be exposed to the internet.
What Is an IP Address: Find Yours and Check Someone Else’s
What an IP address is, how IPv4 differs from IPv6, public and private RFC 1918 ranges, how to find your external and internal IP, what GeoIP databases can and cannot tell you about someone else’s address, static and dynamic addresses.
Related tools
.htaccess Generator
Build a ready-made .htaccess file: redirects, HTTPS, blocked files, custom 404 and compression
htpasswd Generator
An .htpasswd line with a browser-computed SHA-1 hash plus a ready .htaccess block for Apache 2.4 with Require valid-user
Robots.txt Generator
Build a robots.txt for your site: crawl rules, blocked service folders, Clean-param and Host for Yandex, and a Sitemap line
Sitemap.xml Generator
Build a valid sitemap.xml from a URL list or a CSV: lastmod, changefreq, priority, limit checks and a downloadable file
Favicon Generator
Make a site icon from a monogram or your own picture: favicon.ico, apple-touch-icon, Android icons, site.webmanifest and ready HTML tags
JSON Schema Generator
Build a draft JSON Schema from a JSON sample: field types, required keys, nested objects and arrays
Regex Generator
Build a regular expression from a task template or break your own pattern down into parts
Open Graph Generator
Build og:title, og:description, og:image and Twitter Card tags for the link preview on social platforms