Support Library
IP Addresses, Subnets and CIDR
An IP address identifies an interface on a network, and a CIDR prefix such as /24 says how many leading bits name the network. The remaining bits number the hosts inside that subnet.
The short answer
An IPv4 address is a 32-bit number, usually written as four decimal octets such as 198.51.100.77. Every address is split into two parts: a network prefix shared by everything on the same subnet, and a host part that is unique within it. CIDR notation, short for Classless Inter-Domain Routing and defined in RFC 4632, writes that split as a slash and a bit count: 198.51.100.64/26 means the first 26 bits are the network.
Each bit you remove from the prefix doubles the size of the block. A /24 holds 256 addresses, a /23 holds 512, and a /16 holds 65,536.
What an IP address is made of
Computers see an IPv4 address as 32 binary digits. Dotted decimal is just a readable way to write it, one number from 0 to 255 for each group of 8 bits. The address 198.51.100.77 is, in binary:
198 .51 .100 .77
11000110 .00110011 .01100100 .01001101
On its own, an address does not tell you which network it belongs to. You also need the prefix length or the subnet mask. A subnet mask is the same idea written as an address: ones for the network bits, zeros for the host bits. A /26 mask is 26 ones followed by 6 zeros, which is 255.255.255.192.
To find the network, a device performs a bitwise AND of the address and the mask. For 198.51.100.77/26 the result is 198.51.100.64. Any other address that produces the same result is on the same subnet and can be reached directly; anything else goes to a router. IPv6 uses the same prefix idea with 128-bit addresses, covered in IPv4 vs IPv6 and AAAA Records.
From address classes to CIDR
Early IPv4 used fixed classes. A Class A network had an 8-bit prefix, Class B 16 bits and Class C 24 bits, and the class was implied by the first few bits of the address. That wasted space badly: an organization too big for a Class C's 254 hosts would often get a Class B with more than 65,000.
CIDR replaced classes in the 1990s. Any prefix length is allowed, so a provider can hand out exactly the block a customer needs, and routers can summarize many adjacent blocks into one route. A provider holding 203.0.113.0/24 can announce that single prefix to the rest of the Internet even if it has split it into dozens of customer subnets internally.
Routers choose between overlapping routes with longest-prefix match: the most specific route that contains the destination wins. If a routing table has both 198.51.100.0/24 and 198.51.100.64/26, traffic to 198.51.100.77 follows the /26. The same rule governs routing between networks on the Internet, as described in BGP Basics: How Internet Routing Works.
CIDR reference table
This table covers the IPv4 prefix lengths you will meet most often. "Usable hosts" subtracts the network and broadcast addresses, which are not assigned to hosts in a normal subnet.
| Prefix | Subnet mask | Addresses | Usable hosts | Typical use |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | Very large allocations; the 10.0.0.0/8 private range |
| /12 | 255.240.0.0 | 1,048,576 | 1,048,574 | The 172.16.0.0/12 private range |
| /16 | 255.255.0.0 | 65,536 | 65,534 | Campus or cloud network blocks |
| /20 | 255.255.240.0 | 4,096 | 4,094 | Larger site or VPC subnets |
| /22 | 255.255.252.0 | 1,024 | 1,022 | Medium networks |
| /24 | 255.255.255.0 | 256 | 254 | The classic LAN subnet; smallest prefix widely accepted in global routing |
| /25 | 255.255.255.128 | 128 | 126 | Half a /24 |
| /26 | 255.255.255.192 | 64 | 62 | Small server or office subnets |
| /27 | 255.255.255.224 | 32 | 30 | Small segments |
| /28 | 255.255.255.240 | 16 | 14 | Small customer blocks |
| /29 | 255.255.255.248 | 8 | 6 | Small static IP blocks |
| /30 | 255.255.255.252 | 4 | 2 | Traditional point-to-point links |
| /31 | 255.255.255.254 | 2 | 2 | Point-to-point links (RFC 3021) |
| /32 | 255.255.255.255 | 1 | 1 | A single host, such as a loopback or a host route |
The formula behind the "Addresses" column is 2 raised to the number of host bits. A /26 has 32 minus 26, or 6, host bits, and 2 to the 6th is 64.
Working through a subnet
Suppose you are given 198.51.100.0/24 and need four equal subnets. Borrowing 2 bits from the host part makes four /26 blocks of 64 addresses each:
A host configured as 198.51.100.77/26 lives in the second block. On Linux, the ip command shows the address, its prefix, the broadcast address and the connected route the kernel built from them:
$ ip -4 addr show dev eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
inet 198.51.100.77/26 brd 198.51.100.127 scope global eth0
valid_lft forever preferred_lft forever
$ ip -4 route
default via 198.51.100.65 dev eth0 proto static
198.51.100.64/26 dev eth0 proto kernel scope link src 198.51.100.77
The second route says every address in 198.51.100.64/26 is reachable directly on eth0. Everything else goes to the default gateway at .65. A wrong prefix length is a classic cause of "some hosts reachable, others not": with a /24 configured by mistake, this host would try to reach 198.51.100.200 directly instead of through the router.
Blocks must start on a boundary that matches their size. 198.51.100.64/26 is valid because 64 is a multiple of 64; 198.51.100.70/26 is not a network address, and tools will either reject it or quietly round it down to .64.
Where prefixes show up in DNS work
DNS operators work with CIDR more often than it might seem:
- Reverse DNS. PTR records live under in-addr.arpa, which is organized by octet. A /24 maps neatly to one reverse zone, such as 100.51.198.in-addr.arpa. Blocks smaller than a /24 cannot be delegated on an octet boundary, so providers use the CNAME-based technique in RFC 2317. See Reverse DNS and PTR Records.
- SPF. The ip4: and ip6: mechanisms accept prefixes, for example v=spf1 ip4:192.0.2.0/24 -all. A prefix that is too wide authorizes far more senders than intended.
- Access control. Recursion, zone transfer and dynamic update permissions on name servers are usually written as lists of prefixes. An open resolver is often just an access list that says 0.0.0.0/0.
- EDNS Client Subnet. Some resolvers pass a truncated client prefix, often a /24 for IPv4, to authoritative servers so they can tailor geographic answers, as described in RFC 7871.
Not every address is meant for the public Internet. Ranges such as 10.0.0.0/8 are reserved for private use and must be translated before they can reach it; NAT and Private IP Address Ranges covers those blocks.
How DNS Panopticon helps
The Subnet Calculator works through any IPv4 or IPv6 block for you. It draws every bit of the address, mask, network and broadcast address so you can see where the network part ends, marks your address on the range, and splits a block into smaller subnets like the four /26s above.
Website Recon resolves a domain's A and AAAA records and looks up each resulting IP address in RDAP to find the network it belongs to and its autonomous system number. That tells you which registered block, and which operator, a name's addresses sit in without working out the prefix by hand.
If you manage a zone export, Zone Analyzer lets you build filters on the record data column, for example records whose data starts with a given network's leading octets, which is a quick way to list every name that points into one subnet before renumbering it.
When an address "should" be reachable but is not, write down its prefix length, the network address, and the gateway, then check that all three agree. Most subnet mistakes are visible in one ip route output.
FAQ
What does the /24 in 192.0.2.0/24 mean?
It is the prefix length. The first 24 bits of the address identify the network and the last 8 bits identify hosts inside it, so 192.0.2.0/24 covers 256 addresses from 192.0.2.0 to 192.0.2.255. It is the same as the subnet mask 255.255.255.0.
Why does a /24 only have 254 usable host addresses?
In a normal IPv4 subnet the first address is the network address and the last is the broadcast address, so neither is assigned to a host. That leaves 256 minus 2. Point-to-point links can use a /31 with both addresses usable, and a /32 names a single host.
Where do CIDR prefixes appear in DNS?
In several places: SPF ip4 and ip6 mechanisms, access lists for zone transfers and recursion, EDNS Client Subnet data sent by resolvers, and reverse DNS, where delegation of in-addr.arpa zones follows octet boundaries and smaller blocks need classless delegation.