Networking

IP Subnet Calculator

Free IP subnet calculator. Enter an IPv4 address and a CIDR prefix to get the subnet mask, network, broadcast, first and last host, and the usable hosts.

Share:X
Loading calculator interface...

How the IP Subnet Calculator Works


An IPv4 address, such as 192.168.1.10, is a 32-bit number written as four parts. A subnet is a block of addresses that share the same first part, called the network part. The prefix length (CIDR) says how many of the 32 bits belong to the network. The rest are for the devices, called hosts. The IP Subnet Calculator uses the prefix to find the mask, the range and the number of hosts.

What you enter

  • The IPv4 address, four numbers from 0 to 255 separated by dots.
  • The prefix length, a number from 0 to 32, written after a slash. For example, /24.

The steps

mask      = the first (prefix) bits set to 1, the rest set to 0
wildcard  = the opposite of the mask
network   = address AND mask
broadcast = network OR wildcard
total     = 2 ^ (32 - prefix)
usable    = total - 2

The first usable host is the network address plus 1. The last usable host is the broadcast address minus 1. Two addresses in each subnet are kept: the network address (the first) names the subnet, and the broadcast address (the last) reaches every device in it.

Worked example: 192.168.1.10/24

ResultValue
Subnet mask255.255.255.0
Wildcard mask0.0.0.255
Network address192.168.1.0
Broadcast address192.168.1.255
First and last usable host192.168.1.1 and 192.168.1.254
Total addresses256
Usable hosts254

A second example: 192.168.1.130/26

A /26 has 6 host bits, so each subnet has 64 addresses. The address 192.168.1.130 is in the subnet that starts at 192.168.1.128.

ResultValue
Subnet mask255.255.255.192
Network address192.168.1.128
Broadcast address192.168.1.191
Usable hosts62 (192.168.1.129 to 192.168.1.190)

Chart: the 32 bits of an address

Green bits are the network part, and amber bits are the host part. Each block is one bit.

/8   ████████████████████████████████
/16  ████████████████████████████████
/20  ████████████████████████████████
/24  ████████████████████████████████
/26  ████████████████████████████████
/30  ████████████████████████████████

Every extra network bit halves the size of the subnet.

Common prefixes

PrefixSubnet maskTotal addressesUsable hosts
/8255.0.0.016,777,21616,777,214
/16255.255.0.065,53665,534
/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 (point-to-point)
/32255.255.255.25511 (a single host)

Chart: usable hosts from /24 to /30

Each block is about 6.4 hosts. A bar of at least one block is always drawn.

/24  ████████████████████████████████████████ 254
/25  ████████████████████ 126
/26  ██████████ 62
/27  █████ 30
/28  ██ 14
/29  █ 6
/30  █ 2

Special cases: /31 and /32

  • /31 has only 2 addresses. By the rule "total minus 2" it would have none, but a standard called RFC 3021 allows both addresses to be used on a link between two devices. The calculator shows 2 usable hosts.
  • /32 is a single address, used for one device such as a loopback or a route to one host. The calculator shows 1 host.

The type of address

The calculator also tells you what kind of address you entered:

RangeType
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16Private, for use inside a home or an office
127.0.0.0/8Loopback, this computer
169.254.0.0/16Link-local, self-assigned when no server answers
100.64.0.0/10Shared space used by internet providers (carrier-grade NAT)
224.0.0.0 to 239.255.255.255Multicast
240.0.0.0 and aboveReserved
Everything elsePublic

The class (A, B, C, D or E) comes from the first number of the address. It is the old way of sizing networks, and today the prefix length is what counts.

Tips

  • Choose the prefix from the hosts you need. Add 2 to the number of devices, then take the smallest block that is big enough. For 50 devices, 52 addresses need a /26 (64 addresses).
  • Leave room to grow. Changing a subnet later is more work than choosing a bigger one now.
  • Type the address as four plain numbers. Numbers with a leading zero, such as 010, are not accepted, because some systems read them as octal.

What this calculator does not include

  • IPv6 addresses.
  • Splitting a network into several smaller subnets (VLSM), or joining networks into a summary route.
  • Checking whether an address is free or in use on your network.

This tool is for planning and learning. Always check the design of a real network before you change equipment.

Frequently Asked Questions

Is the IP Subnet Calculator free to use?+

Yes. The IP Subnet Calculator, and every other tool on CalculatorBooth, is completely free to use with no sign-up or account required.

Is my data stored or shared?+

All computations are performed locally in your browser. No private inputs or parameters are stored or transmitted.

How accurate is this calculator?+

It's built and tested for accuracy, but the result is an estimate for planning purposes. It isn't a substitute for advice from a qualified financial, medical, or legal professional.

Related Calculators