radixflip

Online Subnet Calculator

Enter an IPv4 address and a CIDR prefix — everything updates live: network address, broadcast address, usable host range, wildcard mask and IP class.

Calculate Your Subnet

192.168.1.10/24 — network 192.168.1.0, broadcast 192.168.1.255, 254 usable hosts.

IPv6 subnet calculator →  ·  Full calculator (all bases, all operations) →

How to calculate a subnet

  1. Enter the IP address and prefix. Type an IPv4 address such as 192.168.1.10 and a CIDR prefix such as 24. The prefix counts the network bits; the rest are host bits.
  2. Find the network address. AND the address with the subnet mask. For 192.168.1.10/24 the mask is 255.255.255.0 and the network address is 192.168.1.0.
  3. Find the broadcast address. OR the address with the wildcard mask. For a /24 the wildcard mask is 0.0.0.255 and the broadcast address is 192.168.1.255.
  4. Count the usable hosts. Usable hosts run from one above the network address to one below the broadcast address. A /24 gives 28 − 2 = 254 usable hosts.

Worked example: 192.168.1.10/24

ValueResult
IP address192.168.1.10
CIDR/24
Subnet mask255.255.255.0
Wildcard mask0.0.0.255
Network address192.168.1.0
Broadcast address192.168.1.255
First usable host192.168.1.1
Last usable host192.168.1.254
Usable hosts254
IP classClass C · Private

The math: /24 leaves 32 − 24 = 8 host bits. Total addresses 28 = 256. Subtract the network address and the broadcast address: 256 − 2 = 254 usable hosts.

Special cases: /31 and /32

A /31 has only 2 addresses and, per RFC 3021, both are usable — there is no separate network or broadcast address. It is used for point-to-point links. A /32 is a single host address: network, broadcast, first and last address are all the same address, with 1 usable host. This calculator shows those cases automatically when you enter prefix 31 or 32.

How to calculate a subnet in code

Python

import ipaddress

net = ipaddress.IPv4Network("192.168.1.10/24", strict=False)
print(net.network_address)    # 192.168.1.0
print(net.broadcast_address)  # 192.168.1.255
print(net.netmask)            # 255.255.255.0
print(net.hostmask)           # 0.0.0.255 (wildcard mask)
print(net.num_addresses)      # 256
print(list(net.hosts())[0])   # 192.168.1.1
print(list(net.hosts())[-1])  # 192.168.1.254

The strict=False flag lets you pass a host address like 192.168.1.10 instead of the network address itself.

Frequently asked questions

What is a subnet calculator?

It is a tool that takes an IPv4 address and a CIDR prefix (or a netmask) and works out the network address, broadcast address, usable host range, number of usable hosts, wildcard mask and IP class. Type an address and prefix above and every value updates live — no button to press.

How do I calculate a subnet?

Write the IP address and the prefix, for example 192.168.1.10/24. The /24 means the first 24 bits are the network part and the remaining 8 bits are host bits. AND the address with the mask 255.255.255.0 to get the network address 192.168.1.0. OR the address with the wildcard mask 0.0.0.255 to get the broadcast address 192.168.1.255. Usable hosts run from 192.168.1.1 to 192.168.1.254.

How many usable hosts in a /24?

A /24 has 254 usable hosts. It leaves 32 − 24 = 8 host bits, so there are 2^8 = 256 total addresses. Subtract the network address and the broadcast address and 254 remain: 192.168.1.1 through 192.168.1.254.

What is a wildcard mask?

The wildcard mask is the bitwise inverse of the subnet mask: every 0 in the mask becomes 1 and every 1 becomes 0. For a /24 the mask is 255.255.255.0 and the wildcard mask is 0.0.0.255. Routers and access-control lists use wildcard masks to match a whole range of addresses.

What is CIDR?

CIDR (Classless Inter-Domain Routing) writes a network as an IP address plus a prefix length, like 192.168.1.10/24. The number after the slash counts how many leading bits belong to the network. /24 means the same as netmask 255.255.255.0. CIDR replaced the old fixed classful boundaries, so a network can be any size from /0 to /32.

What is the difference between the network and broadcast address?

The network address is the first address of a subnet, with all host bits set to 0 — it identifies the subnet itself, for example 192.168.1.0. The broadcast address is the last address, with all host bits set to 1 — for example 192.168.1.255. Sending to the broadcast address reaches every host on that subnet. Neither address can be assigned to an ordinary host.

IPv6 subnet calculator →  ·  Full calculator (all bases, all operations) →