Subnet calculator for IPv4 addresses and CIDR prefixes

IPv4 subnet from CIDR notation: network, broadcast, mask and host count.

Rules reviewed: BS / EN
01

Your inputs

Starting values are an example. Replace them with your own.

Your inputs stay in your browser.

02

Your result

Enter your details and run the calculation.

About this result

Informational calculations. Check assumptions, dates and jurisdiction before making a decision.

Full disclaimer

How an IPv4 subnet follows from the CIDR prefix

Planning a home lab, a small office network or an address block in a cloud account starts with one line such as 10.20.30.40/22, and everything else follows from the prefix. Type the address with its prefix and the calculator returns the network and broadcast addresses, the subnet and wildcard masks, the first and last usable host and the number of hosts. It works with IPv4 addresses only, which is enough for most exam questions and router configs.

The prefix sets how many of the 32 address bits belong to the network, and the number of usable hosts is 2^(32 − prefix) − 2. Example: 192.168.1.10/26 has the mask 255.255.255.192 and wildcard 0.0.0.63, network address 192.168.1.0 and broadcast 192.168.1.63. The first usable host is 192.168.1.1 and the last is 192.168.1.62, 62 hosts in total. A /31 gives 2 addresses for a point to point link under RFC 3021, and a /32 marks a single host. Check the powers of two in the host formula with the powers and roots calculator, or enter the whole expression in the online scientific calculator.

Worked example

A networking student in Edinburgh is given 172.16.5.130/27 in a lab exercise and has to find which subnet the address belongs to.

Inputs

IPv4 address with prefix
172.16.5.130/27

Result

Network
172.16.5.128/27
Broadcast
172.16.5.159
Subnet mask
255.255.255.224
Wildcard mask
0.0.0.31
First and last host
172.16.5.129 to 172.16.5.158
Usable hosts
30

Frequently asked questions

How many hosts does a /24 network have?

A /24 network has 256 addresses and 254 usable hosts, because the network address and the broadcast are not assigned to devices. The mask is 255.255.255.0.

What is a wildcard mask?

A wildcard mask is the inverted subnet mask: each octet is subtracted from 255. For the mask 255.255.255.192 the wildcard is 0.0.0.63, and it is used in ACL rules on Cisco routers.

Why is the network address different from the one I typed?

The address you type can be any host inside the subnet, and the calculator clears the host bits with the mask to find the network. For 10.20.30.40/22 the mask is 255.255.252.0, so the network is 10.20.28.0/22 and the broadcast 10.20.31.255. That block holds 1,022 usable hosts, from 10.20.28.1 to 10.20.31.254, which is why even the third octet changes.

METHOD

Formula and method

Mask = 2³² − 2^(32 − prefix). Network = address AND mask. Broadcast = network OR NOT mask. Hosts = 2^(32 − prefix) − 2.