🌐 Network Engineering Tool

Subnet Mask Calculator

Enter an IPv4 address and CIDR prefix to instantly get the subnet mask, network address, broadcast, usable host range, wildcard mask, and binary breakdown.

/
Prefix length /24
/0/8/16/24/32

Binary view β€” network bits vs host bits

Network bits Host bits CIDR boundary

What is a subnet mask?

A subnet mask is a 32-bit number that separates an IPv4 address into two parts: the network portion and the host portion. It tells devices which part of an IP address identifies the network and which part identifies a specific device (host) on that network. Routers and switches use this mask to decide whether a destination is local or must be forwarded to another network.

IPv4 addresses in brief

An IPv4 address is written as four decimal octets separated by dots, for example 192.168.1.10. Each octet represents 8 bits, so the full address is 32 bits. The subnet mask uses the same format β€” for instance 255.255.255.0 β€” where 255 means "this bit belongs to the network" and 0 means "this bit belongs to the host."

CIDR notation explained

CIDR (Classless Inter-Domain Routing) notation is a compact way to write a subnet mask. Instead of writing 255.255.255.0, you write /24 after the IP address. The number after the slash is the count of consecutive 1-bits in the mask, starting from the left. So /24 means the first 24 bits are network bits and the remaining 8 bits are host bits.

Network bits vs host bits

In a /24 network, the first three octets (192.168.1) are the network bits and the last octet is the host bits. Changing the host bits gives you different devices on the same network; changing the network bits means you are on a different subnet. The boundary between network and host bits is determined entirely by the CIDR prefix.

The classic /24 example

For 192.168.1.0/24:

  • β€’ Subnet mask: 255.255.255.0
  • β€’ Network address: 192.168.1.0
  • β€’ Broadcast address: 192.168.1.255
  • β€’ First usable host: 192.168.1.1
  • β€’ Last usable host: 192.168.1.254
  • β€’ Total addresses: 256
  • β€’ Usable hosts: 254

Network vs broadcast address

The network address is the lowest address in a subnet β€” all host bits are 0. It identifies the subnet itself and cannot be assigned to a device. The broadcast address is the highest address β€” all host bits are 1. Packets sent to the broadcast address are delivered to every device in that subnet. Neither address is usable for a normal host.

Usable hosts and special cases

For most prefixes, the number of usable hosts is 2^(host bits) βˆ’ 2 because the network and broadcast addresses are reserved. Two exceptions exist:

  • β€’ /31 β€” point-to-point links. Both addresses are usable, giving 2 hosts with no network or broadcast address.
  • β€’ /32 β€” a single host route. The address refers to one specific device; there is no host range.

Wildcard mask

A wildcard mask is the bitwise inverse of the subnet mask. Where the subnet mask has a 1, the wildcard has a 0, and vice versa. Wildcard masks are used in Cisco ACLs and OSPF configurations to match ranges of addresses. For /24 the subnet mask is 255.255.255.0 and the wildcard is 0.0.0.255.

Practical examples

10.0.0.0/8

Large private network β€” 16,777,214 usable hosts. Common in enterprises and cloud VPCs.

172.16.0.0/12

Private range β€” 1,048,574 usable hosts. Often used for medium-sized internal networks.

192.168.1.0/24

Home or small office β€” 254 usable hosts. The most common residential subnet.

203.0.113.5/32

Single host route β€” used for loopback interfaces and host-specific routing entries.

Frequently asked questions

What is a subnet mask used for?

A subnet mask divides an IP address into network and host portions. It allows devices and routers to determine whether a destination IP is on the local network or needs to be routed to another subnet.

How do I calculate a subnet mask from CIDR?

Write the CIDR prefix as a series of 1s followed by 0s to fill 32 bits, then group into four octets and convert to decimal. For example, /24 = 24 ones + 8 zeros = 11111111.11111111.11111111.00000000 = 255.255.255.0.

What is the difference between a network address and a broadcast address?

The network address has all host bits set to 0 and identifies the subnet. The broadcast address has all host bits set to 1 and reaches every device in the subnet. Neither can be assigned to a host (except in /31 point-to-point links).

How many usable hosts are in a /24 subnet?

A /24 subnet has 256 total addresses. Subtracting the network and broadcast addresses leaves 254 usable host addresses.

What is a wildcard mask and when is it used?

A wildcard mask is the bitwise inverse of the subnet mask. It is used in Cisco ACLs and routing protocols like OSPF to match ranges of IP addresses. For a /24 subnet, the wildcard mask is 0.0.0.255.

What are the /31 and /32 special cases?

/31 is used for point-to-point links (RFC 3021) and provides 2 usable addresses with no network or broadcast address. /32 represents a single host route and has no host range β€” the address identifies one specific device.

Can I use this calculator for public and private IP addresses?

Yes. The subnet math is identical for public and private IPv4 addresses. The calculator treats any valid IPv4 address the same way and shows the full network breakdown.

What is the largest and smallest subnet possible?

/0 represents the entire IPv4 internet (0.0.0.0 to 255.255.255.255). /32 is the smallest β€” a single host. Most real-world networks fall between /8 and /30.