How IPv4 Addresses and Netmasks Function
An IPv4 address consists of 32 binary bits divided into four 8-bit octets separated by dots (e.g., 192.168.1.1). The subnet mask determines which portion of those 32 bits designates the Network ID (routing prefix) and which portion represents assignable Host devices.
In CIDR (Classless Inter-Domain Routing) notation, a slash followed by a number indicates how many leading bits are frozen for the network. For example, /24 means the first 24 bits are 1s (255.255.255.0), leaving 8 bits for host addresses.
The Formula for Usable Host Calculations
The total number of IP addresses in any subnet is 2^(32 - CIDR). However, in standard IPv4 routing, two addresses are reserved: the first address (all host bits 0) is the Network ID, and the last address (all host bits 1) is the Broadcast Address.
Therefore, Usable Hosts = 2^(32 - CIDR) - 2. For a /24 network, 2^8 - 2 = 254 usable host addresses.
Step-by-Step Tutorial
Identify IP & Prefix
Determine the host IP and required network capacity (e.g., 10.0.0.0 with /20 prefix).
Calculate Network Boundary
Use bitwise AND logic between the IP and mask to find the first network IP.
Determine Assignable Range
Add 1 to the network address for the first host and subtract 1 from the broadcast for the last host.
Ready to Try It Yourself?
DocSwift processes everything directly on your device. Fast, safe, and completely free forever.
How helpful was this guide?
Rated 4.9 / 5 by 3,420+ users worldwide
Share with Colleagues & Friends
Help others protect their document privacy
Frequently Asked Questions
What is the difference between a /24 and /16 subnet?
A /24 subnet has 256 total IPs (254 usable hosts), whereas a /16 subnet provides 65,536 total IPs (65,534 usable hosts).
What is a /31 subnet used for?
Under RFC 3021, /31 subnets (2 total IPs) are specifically designed for point-to-point router links where network and broadcast addresses are unnecessary.