Code

Linus Torvalds

Talk is cheap. Show me the code.

Subnet Details

CIDR or IP mask format.

About this tool

How subnet masks and CIDR work

An IPv4 address has 32 bits. A subnet mask says how many of those bits identify the network and how many identify hosts on it. CIDR notation writes that as a prefix length: 192.168.1.0/24 means the first 24 bits are the network, so the mask is 255.255.255.0 and 8 bits are left for hosts.

Usable hosts on a subnet = 2(32 − prefix) − 2. The two addresses taken out are the network address (all host bits 0) and the broadcast address (all host bits 1). The exceptions are /31, which is used for point-to-point links (RFC 3021), and /32, which is a single host.

Common prefix lengths

CIDRNetmaskUsable hosts
/24255.255.255.0254
/25255.255.255.128126
/26255.255.255.19262
/27255.255.255.22430
/28255.255.255.24014
/29255.255.255.2486
/30255.255.255.2522
/31255.255.255.2542 (point-to-point)
/32255.255.255.2551 (single host)

FAQ

How many hosts are in a /27? A /27 has 32 addresses and 30 usable hosts.

What is a wildcard mask? It is the inverse of the subnet mask (for /24, 0.0.0.255). Access lists and OSPF network statements on many routers use it.

What are private IPv4 ranges? 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 (RFC 1918).