IP Address Structure: Network Bits, Host Bits, Subnet Mask and CIDR
IP in Binary
An IPv4 address is a 32-bit number, usually written in dotted decimal like 192.168.1.1. Each of the four octets is 8 bits, so each ranges from 0 to 255.
Network Bits and Host Bits
An address consists of network bits (identifying the subnet) and host bits (identifying a device inside it). The subnet mask, such as 255.255.255.0, marks the boundary.
CIDR Notation
CIDR writes a range as IP/prefix, e.g. 192.168.1.0/24 means the first 24 bits are network bits - equivalent to mask 255.255.255.0. A /24 has 256 addresses; two are reserved for network and broadcast, leaving 254 usable.
Common Prefixes
| CIDR | Subnet Mask | Total | Usable |
|---|---|---|---|
| /30 | 255.255.255.252 | 4 | 2 |
| /29 | 255.255.255.248 | 8 | 6 |
| /28 | 255.255.255.240 | 16 | 14 |
| /24 | 255.255.255.0 | 256 | 254 |
| /16 | 255.255.0.0 | 65536 | 65534 |
| /8 | 255.0.0.0 | 16777216 | 16777214 |