Skip to content

Subnets and CIDR notation

Updated

Every IP address has two parts: the network it belongs to, and the device within that network. A prefix length says how many of the leading bits name the network. Written after a slash, it gives CIDR notation (Classless Inter-Domain Routing).

192.168.1.0/24

Here /24 means the first 24 bits, which are the first three numbers, name the network. The last 8 bits are free for devices. The same split is also written as a subnet mask: /24 is 255.255.255.0.

How many addresses fit

In IPv4 a prefix of /n leaves 32 minus n bits for devices, so the subnet holds 2 to the power of (32 minus n) addresses. Each step of one in the prefix halves or doubles the size.

  • /16 holds 65,536 addresses (65,534 usable)
  • /24 holds 256 addresses (254 usable)
  • /25 holds 128 addresses (126 usable)
  • /26 holds 64 addresses (62 usable)
  • /30 holds 4 addresses (2 usable)

Good to know. The first address of an IPv4 subnet (the network address) and the last (the broadcast address) are not given to devices. In 192.168.1.0/24 the usable addresses run from 192.168.1.1 to 192.168.1.254. Two special cases: a /31 is used for point-to-point links, and a /32 is a single address.

IPv6

IPv6 works the same way with 128 bits. A single local network is normally a /64, so subnets are enormous and nobody counts usable hosts. A provider typically gives a site a shorter prefix, such as a /56 or /48, so it can have many /64 networks.

Try it in the subnet calculator