CalcMate

IP Subnet Calculator

Enter an IPv4 address and a prefix length and the calculator returns the network address, the broadcast address, the usable host range and both masks — plus the smallest subnet that fits however many hosts you need.

Network address192.168.1.0
Broadcast address192.168.1.255
Usable hosts254
First usable address192.168.1.1
Last usable address192.168.1.254
Addresses in the block network and broadcast included256
Subnet mask255.255.255.0 (/24)
Wildcard mask inverse of the netmask0.0.0.255
Address typePrivate (RFC 1918, 192.168.0.0/16) — Class C range
Mask for 50 hosts/26 (255.255.255.192) — 62 usable hosts, the smallest subnet that holds 50.

Usable hosts follow the 2^n - 2 rule: with n host bits, the all-zeros network address and the all-ones broadcast address are reserved, so a /24 holds 254 devices. A /31 is the documented exception — RFC 3021 lets a point-to-point link use both of its addresses, which is why the count above shows 0 — and a /32 is a single host route with one usable address. Masks are shown with no class assumption: under CIDR any prefix from /0 to /32 can be applied to any address, and every subnet boundary must land on a multiple of its own block size.

Formula and calculation

Network=IP AND maskBroadcast=network OR NOT maskUsable hosts=2n−2, where n=32−prefix\begin{gathered}\text{Network} = \text{IP AND mask}\\[6pt]\text{Broadcast} = \text{network OR NOT mask}\\[6pt]\text{Usable hosts} = 2^n - 2\text{, where } n = 32 - \text{prefix}\end{gathered}
These are the standard definitions of IPv4 subnetting: the network address is the bitwise AND of the address with the mask, the broadcast address has all the host bits set to 1, and the usable-host count leaves both of those addresses out. CIDR prefix notation is defined in RFC 4632 and the 2^n - 2 rule comes from the original subnetting specification in RFC 950.

Worked example

For 192.168.1.130/26 the network address is 192.168.1.128 and the broadcast address is 192.168.1.191, so devices can use 192.168.1.129 through 192.168.1.190 — 62 host addresses in a block of 64.

Choosing a mask from the number of hosts

Count the devices you need, add room to grow, then take the smallest block that fits: a /30 holds 2 devices, /29 holds 6, /28 holds 14, /27 holds 30, /26 holds 62, /25 holds 126, /24 holds 254 and /23 holds 510. Every step halves the block size and doubles the number of subnets.

Two habits save trouble later. First, round up to the next size, because adding a subnet in the middle of an addressing plan is painful: two blocks of 62 are easier to manage than one block of 100. Second, keep the boundaries on the block size — a /26 must start at a multiple of 64 in the last octet, so 192.168.1.128/26 is valid and 192.168.1.130/26 is not where the block begins.

What the results mean

Network address
The first address of the subnet — the one with every host bit set to 0. It names the subnet and cannot be given to a device.
Broadcast address
The last address of the subnet, with every host bit set to 1. A packet sent here reaches every host on the subnet, so it is reserved too.
First usable address
The lowest address you can actually assign to a device: the network address plus one.
Last usable address
The highest address you can assign to a device: one below the broadcast address.
Usable hosts
How many device addresses the subnet leaves, from the standard 2^n - 2 rule, where n is the number of host bits. A /24 gives 254 and a /26 gives 62.
Addresses in the block
The total size of the subnet, network and broadcast addresses included. It is always a power of two, which is why subnet boundaries fall on numbers like 64, 128 and 192.
Subnet mask
The subnet mask in dotted-decimal form with its prefix length, for example 255.255.255.192 (/26). This is the value to type into a router or a host configuration.
Wildcard mask
The inverse of the subnet mask, also called a wildcard or host mask — 0.0.0.63 for a /26. Cisco access lists, OSPF and some firewall rules want this form instead of the mask.
Address type
What the address is for: private (RFC 1918), loopback, link-local, carrier-grade NAT, documentation, multicast, reserved or public, with its traditional class letter.
Mask for 50 hosts
The smallest subnet that fits the number of hosts you asked for, with its mask and usable host count. Grow it one step if the subnet has to leave room for new devices.

Frequently asked questions

How many usable hosts does a /26 subnet have?

62. A /26 is 64 addresses (2^6), and the first and last are the network and broadcast addresses, so 64 - 2 = 62 devices fit. Its mask is 255.255.255.192, and the blocks start at 0, 64, 128 and 192 in the last octet.

Does this calculator support IPv6?

No — it handles IPv4 only. IPv6 has no broadcast address at all and a /64 is the standard size for a LAN, so the 2^n - 2 arithmetic that fills this page does not carry over. For IPv6, count addresses with 2^n and subtract nothing.

Which subnet mask do I need for 100 devices?

A /25, which is 255.255.255.128 and holds 126 usable addresses. Put 100 in the hosts needed field and the calculator names the mask; a /26 would only give you 62, which is short by 38 addresses.

What is a wildcard mask used for?

It is the bitwise inverse of the subnet mask, so 255.255.255.192 becomes 0.0.0.63. Cisco access lists, OSPF and EIGRP statements, and some firewall rules are written with the wildcard because it marks which bits are free to vary rather than which bits are fixed.

Why does a /31 or /32 show no usable hosts?

The classic 2^n - 2 rule sets aside the network and broadcast addresses, and at /31 there are only two addresses to begin with. RFC 3021 allows a point-to-point link to use both of them, which is common on router-to-router links, and a /32 is a single host route with exactly one address.