Subnet Mask and Network Calculation

Calculate IPv4 network, broadcast, usable range, and routing decisions from CIDR

animation
networking
ip-addressing
subnetting
cidr
An interactive IPv4 subnet calculation workbench showing CIDR masks, bitwise AND, broadcast address, usable host range, device-fit checks, and routing decisions.
IPv4 CIDR Bitwise AND IoT segmentation

Subnet masks turn one IPv4 address into a network plan.

Pick an address and prefix, then watch the mask preserve network bits, clear host bits, and produce the network, broadcast, usable range, and route decision that an IoT gateway or host uses.

32 bits IPv4 address width
/n prefix n network bits
IP AND mask Network address

Binary subnet calculator

Network bits are preserved by mask 1s. Host bits are cleared for the network address and set for the broadcast address.

Fits subnet
26 network bits Shared subnet prefix
6 host bits Device addresses
192.168.10.66/26 Mask 255.255.255.192
IP bits
Mask bits
AND result
Broadcast
Network 192.168.10.64
Broadcast 192.168.10.127
Usable range 192.168.10.65 to 192.168.10.126
Step 1: Read the dotted decimal address.

Each octet is 8 bits. The prefix decides how many bits are network bits before any decimal range is calculated.

What is a subnet?

A subnet is the group of IPv4 addresses that share the same network prefix. Devices inside it can usually talk locally; other prefixes need routing.

What does /26 mean?

The first 26 bits are network bits. The remaining 6 bits identify addresses inside that one subnet.

Why use bitwise AND?

AND with mask 1 keeps a bit. AND with mask 0 clears a bit. That turns any host address into its network address.

Why IoT teams care

Subnets separate cameras, sensors, gateways, and control systems so routing, firewall policy, broadcast traffic, and address capacity stay manageable.

Dotted decimal

Four octets become one 32-bit value before the mask is applied.

CIDR mask

The prefix length builds a run of 1 bits followed by host-side 0 bits.

Network AND

IP AND mask preserves the prefix and clears the host portion.

Broadcast

Set host bits to 1 to find the IPv4 directed broadcast address.

Usable range

Ordinary subnets exclude network and broadcast; /31 and /32 are special cases.

Route decision

If the peer has the same network address, local delivery is possible. Otherwise use a router.

Subnet type Ordinary IPv4 subnet

Network and broadcast addresses are reserved, so usable host count subtracts two.

Capacity fit 48 devices fit

This subnet has 62 usable host addresses for the current IoT device target.

Peer route Peer is local

Both addresses reduce to the same network address, so no router is needed for this peer.

Formula trace 2^(32 - 26) - 2 = 62

Mask 255.255.255.192 keeps 26 network bits and leaves 6 host bits.

Compact quick reference

Prefix Mask Usable IPv4 hosts
/24 255.255.255.0 254
/26 255.255.255.192 62
/29 255.255.255.248 6
/31 255.255.255.254 2 endpoints on point-to-point links
/32 255.255.255.255 1 single address route

Core formulas

Network: IP AND subnet mask.

Wildcard: inverse of the mask.

Broadcast: network OR wildcard.

Ordinary host count: 2^(host bits) - 2, which is the same as 2^(32 - prefix) - 2.

Common mistakes

Do not treat `/24` as a classful rule. CIDR prefixes can cut across any octet. Also do not subtract two from `/31` or `/32` when the design is a point-to-point link or host route.

Try the sensor VLAN

Use `/26` and notice that 192.168.10.66 and 192.168.10.1 are not in the same subnet. A gateway address should sit inside the same range.

Test a small subnet

Select the `/29` preset and raise device demand above 6. The capacity diagnosis should switch from fit to overrun.

Check edge cases

Select `/31` and `/32`. The workbench changes the usable-host rule so point links and single-host routes are not marked incorrectly.

Why the broadcast address is IPv4-specific

In ordinary IPv4 subnets, the all-host-ones address is the directed broadcast address. IPv6 does not use broadcast, so this page keeps the calculation explicitly scoped to IPv4.

Why /31 and /32 are special

For ordinary IPv4 LAN subnets, network and broadcast are not assigned to hosts. RFC 3021 allows both addresses in a /31 on point-to-point links because there is no broadcast need on that two-endpoint link. A /32 identifies exactly one IPv4 address, commonly as a host route.

How to size an IoT subnet

Pick the smallest subnet that fits devices, gateways, management addresses, and growth. Then separate high-bandwidth cameras, control systems, low-rate sensors, and guest or vendor devices into different prefixes so policy and broadcast domains stay clear.