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.

Everything runs in your browser — your data is never sent to any server.

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

  1. Type the network in CIDR notation, or switch the input to a separate address and prefix
  2. Read the mask, the network and broadcast addresses, and the usable host range
  3. For a mask lookup, enter the prefix — /24 or /26, for instance
  4. 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

NetworkMask and host rangeHosts
192.168.1.0/24255.255.255.0, 192.168.1.1 — 192.168.1.254254
10.0.0.0/8255.0.0.0, 10.0.0.1 — 10.255.255.25416 777 214
172.16.0.0/12255.240.0.0, 172.16.0.1 — 172.31.255.2541 048 574
192.168.0.0/22255.255.252.0, 192.168.0.1 — 192.168.3.2541 022
192.168.1.0/26255.255.255.192, 192.168.1.1 — 192.168.1.6262
192.168.1.0/28255.255.255.240, 192.168.1.1 — 192.168.1.1414
10.0.0.0/9255.128.0.0, 10.0.0.1 — 10.127.255.2548 388 606
10.0.0.0/18255.255.192.0, 10.0.0.1 — 10.0.63.25416 382
172.16.0.0/20255.255.240.0, 172.16.0.1 — 172.16.15.2544 094
8.8.8.0/30255.255.255.252, 8.8.8.1 — 8.8.8.22

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

StepActionResult
1Parse the input192.168.1.0/24 splits into an address and a prefix
2Build the mask24 ones and 8 zeros give 255.255.255.0
3Network addressAND with the mask leaves 192.168.1.0
4Invert the mask255.255.255.0 becomes 0.0.0.255
5Broadcast addressNetwork address OR the inverted mask: 192.168.1.255
6Address count8 host bits give 2 to the 8th power, 256
7Host countSubtract the network and broadcast addresses: 254
8Usable rangeFirst 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

Two addresses inside every subnet are set aside. The network address 192.168.1.0 identifies the subnet itself: no interface gets it, but routers use it to decide which network a packet belongs to. The broadcast address 192.168.1.255 is needed to send a packet to every device on the subnet at once. Both belong to the subnet, yet neither can be assigned to a device, so 254 addresses remain for hosts, forming the usable range 192.168.1.1 to 192.168.1.254.

How does /24 differ from the mask 255.255.255.0

They are two notations for the same thing. The CIDR form says how many leading bits belong to the network: 24 bits out of 32. The dotted-decimal mask spells those same 24 bits as ones and the remaining eight as zeros. Masks are what you type into interface settings, access lists and firewall rules, while CIDR is how routes and address blocks are described. The calculator prints both side by side so nothing has to be converted in your head when a rule moves from one format to the other.

Can I assign a public IP address to myself

No. Addresses from 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 are private: they are not routed on the internet and are handed out locally, so you may configure them without any agreement. A public address belongs to the block owner or to the provider, and until it has been allocated to you in writing, configuring it means fighting the existing user of that address for traffic. The calculator flags public ranges so the mistake shows up before the interface is configured rather than after.

What are address classes A, B and C

Classes are a leftover from the first versions of IP, when networks were carved up strictly by the first octet: A started at 1, B at 128, C at 192, D was set aside for multicast and E was reserved. Classful allocation no longer exists — networks are defined by a prefix, and a single block may hold a thousand addresses or sixteen million. The class still earns its place as a quick orientation label, since the first octet alone tells you whether an address is private or public, so the calculator shows it next to the prefix.

How do I split a /16 into four /18 subnets

Borrowing two host bits turns a /16 into a /18, because 16 plus 2 equals 18. Each borrowed bit doubles the number of parts, so 2 to the power of 2 gives exactly four subnets. Every one of them keeps 14 bits for hosts, which is 16 384 addresses, of which 16 382 go to devices. The subnets follow each other without gaps: 10.0.0.0/18, 10.0.64.0/18, 10.0.128.0/18 and 10.0.192.0/18, all with the mask 255.255.192.0. The splitting mode builds that table in full, with host ranges and broadcast addresses.

What should I count for a /31 or a /32

The minus-two rule does not apply there. A /32 leaves a single address, which is convenient for a loopback interface or a point-to-point link on one machine, and there is nothing to count. A /31 leaves two addresses: RFC 3021 assigns both of them to a router-to-router link, where each side really is usable. For both cases the calculator reports zero usable hosts and adds a note explaining that no addresses are subtracted.

Which ranges count as private

Three blocks from RFC 1918 are private: 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16. The interface labels a few more separately, because they behave differently in practice: loopback 127.0.0.0/8, link-local 169.254.0.0/16 for automatic address assignment, the carrier-grade NAT block 100.64.0.0/10 that mobile providers hand to clients, and the documentation blocks 192.0.2.0/24, 198.51.100.0/24 and 203.0.113.0/24 that exist only for examples in manuals.

Why does a /8 hold so many addresses

Because 24 bits are left for hosts and 2 to the 24th power equals 16 777 216. The block 10.0.0.0/8 covers every address whose first octet is 10, from 10.0.0.0 up to 10.255.255.255. In practice such enormous blocks go to large organisations, which slice them into smaller subnets so that addresses are not wasted and traffic can be kept apart. The calculator reports both the total number of addresses and the host count after the two reserved ones are removed — for a /8 that is 16 777 214.

Related articles

Related tools