Skip to main content
Black Friday: 40% off your first 3 months on any monthly plan with code BF40. Ends Dec 2.See the offer
Varaxon Technologies

Free and open source

Subnet calculator

Type any IPv4 or IPv6 address with a prefix or mask and get the network, broadcast, host range, masks and address type instantly. Plan VLSM subnets or turn an IP range into CIDR blocks. It runs in your browser, nothing is sent anywhere, and the code is MIT licensed.

  • No account needed
  • Public records only
  • Nothing stored

Subnet calculator

Updates as you type, in your browser

CIDR
192.168.1.0/24
Network
192.168.1.0
Broadcast
192.168.1.255
Usable range
192.168.1.1 - 192.168.1.254
Usable hosts
254
Total addresses
256
Subnet mask
255.255.255.0
Wildcard mask
0.0.0.255
Binary mask
11111111.11111111.11111111.00000000
Address type
Private (RFC 1918)
Class
C
Reverse DNS zone
1.168.192.in-addr.arpa

Cheat sheet

IPv4 subnet mask cheat sheet, /16 to /32

IPv4 prefix lengths with subnet mask and host counts
PrefixSubnet maskAddressesUsable hosts
/16255.255.0.065,53665,534
/17255.255.128.032,76832,766
/18255.255.192.016,38416,382
/19255.255.224.08,1928,190
/20255.255.240.04,0964,094
/21255.255.248.02,0482,046
/22255.255.252.01,0241,022
/23255.255.254.0512510
/24255.255.255.0256254
/25255.255.255.128128126
/26255.255.255.1926462
/27255.255.255.2243230
/28255.255.255.2401614
/29255.255.255.24886
/30255.255.255.25242
/31255.255.255.25422
/32255.255.255.25511

Reading the results

What each line means

  • Network is the first address. It names the subnet and is not given to a device.
  • Broadcast is the last address. Packets sent to it reach every host in the subnet.
  • Usable range is what you can assign to devices, gateways and DHCP pools.
  • Address type tells you if a range is private (RFC 1918), CGNAT, link-local, documentation or public. A public address on an internal asset list is worth a second look.
  • Reverse DNS zone is the in-addr.arpa or ip6.arpa zone you'd create for PTR records.

Open source

MIT licensed: use the code in your own tools

The maths behind this page is one dependency-free TypeScript file: IPv4 and IPv6 parsing, RFC 5952 address compression, VLSM planning and range-to-CIDR. It is exactly the code this page runs. Read it, copy it into your scripts or product, and change it as you like under the MIT license.

Download subnet.ts

Link to this calculator from your docs, wiki or runbook:

<a href="https://varaxontech.com/subnet-calculator">Free subnet calculator by Varaxon</a>

After the subnet plan

Scanning those subnets?

Once you know your ranges, scan them with the scanner you already use and upload the export. Varaxon Scan Hub ranks every finding by CISA KEV, EPSS and CVSS and turns it into a report your team or client will act on. Not sure if a CVE matters? Try the free CVE checker.

Questions

Subnet calculator FAQ

How do I calculate a subnet from a CIDR?

The prefix (the number after the slash) says how many bits belong to the network. Set those bits to 1 to get the mask, AND it with the address to get the network, and set the remaining host bits to 1 to get the broadcast. The usable hosts sit in between. The calculator does all of it as you type.

How many usable hosts are in a /24?

254. A /24 has 256 addresses, and the first (network) and last (broadcast) can't be given to devices. In general a subnet has 2^(32 - prefix) addresses and 2^(32 - prefix) - 2 usable hosts.

Why does a /31 show two usable hosts?

RFC 3021 lets a /31 be used for point-to-point links, where neither address is needed as network or broadcast. A /32 is a single host, used for loopbacks and host routes.

What is VLSM?

Variable Length Subnet Masking: cutting one network into subnets of different sizes, so a 100-device office and a 2-address router link don't both waste a /25. Enter how many hosts each subnet needs and the calculator places the largest first so every block stays aligned.

What is a wildcard mask?

The inverse of the subnet mask, used by Cisco ACLs and OSPF. For 255.255.255.0 the wildcard is 0.0.0.255.

Does it work for IPv6?

Yes. Enter any IPv6 address with a prefix, such as 2001:db8::/48, to get the network, last address, address count, how many /64 subnets it holds, the address type and the reverse DNS zone.

Is my data sent anywhere?

No. Every calculation runs in your browser. Nothing you type leaves your device, so it is safe to use with internal address plans.

Can I use the code?

Yes. The calculator is open source under the MIT license: copy it, change it and ship it in your own tools, commercial or not. Keep the license notice.

More free tools

Cookie preferences

Essential site functions remain available whichever option you choose. Your advertising choice is saved on this site. The Scan Hub has a separate choice.

Google and Reddit may receive cookies, identifiers, browser and device information, and your network/IP information. Reject or withdraw at any time. Read the Privacy Policy.