NetCalcLab

IPv4 Subnet Calculator

Enter an IPv4 address in CIDR notation to get the network address, broadcast address, subnet mask, wildcard mask, usable host range, block size and full binary representation — including the /31 and /32 edge cases that most calculators get wrong.

Accepts 192.168.1.10/24 or a bare address with the prefix chosen below.

Setting this overrides any /prefix typed in the address field.

Examples:

How subnet calculation works

Every IPv4 address is 32 bits, normally written as four decimal octets separated by dots. A CIDR prefix length says how many of those bits identify the network. The rest identify the host inside that network.

The calculation itself is three bitwise operations. Masking the address with the subnet mask clears the host bits and produces the network address. OR-ing the wildcard mask onto the network address sets every host bit and produces the broadcast address.

The three operations
Subnet mask     = 1s for the first /prefix bits, 0s afterwards
Network address = IP address AND subnet mask
Broadcast       = Network address OR wildcard mask
Wildcard mask   = NOT subnet mask (bitwise inverse)

Worked through for 192.168.1.10/24:

Worked example
IP address   11000000.10101000.00000001.00001010   192.168.1.10
Subnet mask  11111111.11111111.11111111.00000000   255.255.255.0
             ─────────────────────────────────────  AND
Network      11000000.10101000.00000001.00000000   192.168.1.0

Wildcard     00000000.00000000.00000000.11111111   0.0.0.255
             ─────────────────────────────────────  OR
Broadcast    11000000.10101000.00000001.11111111   192.168.1.255

First host   192.168.1.1      (network address + 1)
Last host    192.168.1.254    (broadcast address − 1)
Total        256 addresses     Usable  254 hosts

Where the subnets start: block size and the interesting octet

The block size is the number of addresses in the subnet. For any prefix from /25 to /32 the block size is a power of two that fits inside a single octet, which gives the fastest manual method: identify the octet that the prefix lands in, then round the address down to the nearest multiple of the block size in that octet.

Example: 192.168.1.100/27

A /27 has 32 addresses, so the block size is 32. The prefix lands in the fourth octet, which makes it the interesting octet. The largest multiple of 32 that is at or below 100 is 96.

Network 192.168.1.96 → Broadcast 192.168.1.127 → Hosts .97 to .126

The next subnet of the same size begins at 192.168.1.128, then 192.168.1.160, 192.168.1.192 and 192.168.1.224 — eight /27s inside the /24.

Edge cases: /0, /30, /31 and /32

Four prefixes behave differently from the general rule, and they are the ones that cause real outages when a calculator gets them wrong.

  • /0 — the default route. It covers the entire IPv4 space, so the “network address” is 0.0.0.0 and the broadcast is 255.255.255.255. There is no meaningful host range. Address counts need 64-bit arithmetic here, because 232 overflows a signed 32-bit integer.
  • /30 — four addresses, two usable. This is the classic WAN transit link size and is still what most point-to-point routing configurations expect.
  • /31 — two addresses with no network or broadcast address. RFC 3021 allows both to be assigned on point-to-point links, so a /31 carries exactly as many usable addresses as a /30 while consuming half the space.
  • /32 — a single host route. Used for loopbacks, anycast addresses and static routes to one device.

The calculator reports both the traditional usable-host count and the RFC 3021 figure for /31 so you can choose whichever convention your design follows.

Example: sizing a department VLAN at 100 hosts

Start from the host requirement and work backwards. You need at least 102 addresses (100 hosts plus the network and broadcast). The powers of two are ...64, 128, 256. 128 is the first that fits, so the host portion needs 7 bits and the prefix is /25.

A /25 gives 126 usable hosts — 26 spare for growth.

A /26 would give only 62 usable hosts, so it is too small. This is the calculation the VLSM planner automates across a whole list of requirements.

Common mistakes this calculator avoids

  • Assuming a /24 is always the network. If the address is 10.1.2.3/8, the network is 10.0.0.0, not 10.1.2.0.
  • Treating the wildcard mask as an alternative spelling of the subnet mask. They are inverses, and swapping them in an ACL inverts the match.
  • Forgetting that the gateway consumes a usable address. A /29 with six usable hosts has five left for devices if the router takes the first one.

Common subnet sizes

The prefixes you meet most often, with their masks and usable host counts.

Common CIDR prefixes with masks and host counts
PrefixSubnet maskTotal addressesUsable hostsTypical use
/8255.0.0.016,777,21616,777,214Very large private or ISP allocation
/16255.255.0.065,53665,534Large campus or enterprise block
/20255.255.240.04,0964,094Large site or ISP customer
/22255.255.252.01,0241,022Branch office or VPN pool
/23255.255.254.0512510Two combined VLANs
/24255.255.255.0256254Standard LAN or VLAN
/25255.255.255.128128126Half a /24
/26255.255.255.1926462Small department
/27255.255.255.2243230Small team or device group
/28255.255.255.2401614Small segment
/29255.255.255.24886Small link segment
/30255.255.255.25242Point-to-point WAN link
/31255.255.255.25422 (RFC 3021)Point-to-point link, no broadcast
/32255.255.255.25511Host route or loopback

A /24 has a block size of 256 and a wildcard mask of 0.0.0.255 — the same value you would use in a Cisco ACL to match the whole subnet.

Frequently asked questions

How do I calculate a subnet from an IP address?

Split the address into its 32 binary bits, then divide them at the prefix length. For 192.168.1.10/24 the first 24 bits are the network and the last 8 are the host. The network address is 192.168.1.0 (all host bits zero) and the broadcast address is 192.168.1.255 (all host bits one). Usable hosts run from 192.168.1.1 to 192.168.1.254.

How many usable hosts are in a /24?

A /24 contains 256 addresses. Under traditional subnetting, two are reserved — the network address and the broadcast address — leaving 254 usable host addresses. A /24 is the most common subnet size for a single VLAN.

What is the difference between a subnet mask and a wildcard mask?

A subnet mask has 1s in the network portion and 0s in the host portion, so a /24 is 255.255.255.0. A wildcard mask is the exact inverse, so the same /24 is 0.0.0.255. Wildcard masks are used in Cisco ACLs and OSPF network statements, where 0 means 'must match' and 1 means 'ignore'.

Why does a /31 show zero usable hosts?

The traditional rule subtracts two addresses for the network and broadcast, and a /31 only has two addresses total. RFC 3021 changed this: on a point-to-point link both addresses of a /31 can be assigned to the two routers at each end, doubling the number of WAN links you can fit in a block. The calculator shows both figures.

How do I find the network address without converting to binary?

Find the block size first — the number of addresses in the subnet. For a /27 the block size is 32. Then find the largest multiple of the block size that is less than or equal to the interesting octet of the address. For 192.168.1.100/27, the interesting octet is the fourth: 32 × 3 = 96, so the network address is 192.168.1.96 and the broadcast is 192.168.1.127.

Is 172.16.0.0 private or public?

172.16.0.0/12 is one of the three RFC 1918 private ranges, covering 172.16.0.0 through 172.31.255.255. The calculator labels it as private and shows the matching range so you can confirm before putting it in a router configuration.