CCalculate.Studio
technology · 7 min · Ultima revisione: 2026-07-07

How IP Subnetting Works: A Beginner's Guide to CIDR

TL;DRA subnet mask is a 32-bit pattern of contiguous 1-bits followed by 0-bits that splits an IPv4 address into a network portion and a host portion, and CIDR notation such as /24 states how many of those 32 bits belong to the network. Subnetting exists to divide a large address block into smaller, independently manageable networks, which limits the size of broadcast domains, isolates traffic and keeps routing tables smaller through address aggregation. For example, the address 192.168.1.10/26 has a mask of 255.255.255.192, giving a network address of 192.168.1.0, a broadcast address of 192.168.1.63, and 62 usable host addresses from 192.168.1.1 through 192.168.1.62.

What a subnet mask does

A subnet mask is a 32-bit value, matched in length to an IPv4 address, made up of a contiguous run of 1-bits followed by a contiguous run of 0-bits. The 1-bits mark which bits of the address identify the network the address belongs to, and the 0-bits mark which bits identify a specific host within that network. Applying a bitwise AND between an IP address and its mask strips away the host bits and leaves only the network address.

For example, the mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000 -- 24 one-bits followed by 8 zero-bits -- meaning the first three octets identify the network and the last octet identifies individual hosts within it, allowing up to 256 addresses (254 of them usable) in that network.

CIDR notation: what /24 actually means

CIDR (Classless Inter-Domain Routing), specified in RFC 4632, writes the subnet mask as a slash followed by the number of leading 1-bits, so /24 is shorthand for the mask 255.255.255.0 and /26 is shorthand for 255.255.255.192. CIDR replaced the older classful system, in which network size was rigidly fixed by the first bits of the address (class A, B or C), with the flexibility to define a network of almost any size by choosing any prefix length from /0 to /32.

The prefix length directly determines both the mask and the number of host bits remaining: for a 32-bit IPv4 address, host bits = 32 − prefix length. A /24 network has 8 host bits (2⁸ = 256 addresses), a /26 network has 6 host bits (2⁶ = 64 addresses), and a /30 network has 2 host bits (4 addresses) -- the smaller the host-bit count, the smaller the network.

Worked example: 192.168.1.10/26

Take the address 192.168.1.10 with a /26 prefix. A /26 mask has 26 one-bits, which covers the entire first three octets (24 bits) plus the top 2 bits of the fourth octet, giving the mask 255.255.255.192 (192 in binary is 11000000). The fourth octet of the address, 10, is 00001010 in binary; ANDing it with the mask's fourth octet (11000000) zeroes out the lower 6 bits, leaving 00000000 = 0, so the network address is 192.168.1.0.

The 6 remaining host bits in the fourth octet give a block size of 2⁶ = 64 addresses per subnet, so the subnet containing .10 spans addresses .0 through .63. The broadcast address is the top of that range, 192.168.1.63 (all host bits set to 1), and the usable host range is everything between the network and broadcast addresses: 192.168.1.1 through 192.168.1.62 -- exactly 2⁶ − 2 = 62 usable host addresses.

Why subnetting exists

Subnetting was standardized in RFC 950 to solve a practical problem: a single flat network of thousands or millions of devices is inefficient and fragile, because every device in a broadcast domain receives every broadcast packet sent within it, and a fault or a broadcast storm on one segment can affect the entire network. Splitting a large address block into smaller subnets confines broadcast traffic to each subnet and lets a network be organized around physical or organizational boundaries -- a floor, a department, a data center rack -- rather than one undivided pool of addresses.

Subnetting also supports address conservation and routing efficiency: an organization can size each subnet to roughly match the number of devices it actually needs (a /30 point-to-point link between two routers does not need to consume 254 addresses like a /24 office network would), and CIDR's variable-length prefixes let routers aggregate many small subnets into a single routing table entry, keeping internet-scale routing tables from growing unmanageably large, as described in RFC 4632.

CIDR prefix reference table

The table below lists common CIDR prefix lengths with their dotted-decimal subnet masks and the resulting number of usable host addresses, following standard CIDR host-counting rules where the network and broadcast addresses are reserved and not assignable to a device.

PrefixSubnet maskUsable 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

Domande frequenti

What is a subnet mask?

A subnet mask is a 32-bit value consisting of a contiguous run of 1-bits followed by a contiguous run of 0-bits, used to split an IPv4 address into a network portion and a host portion. Applying a bitwise AND between an address and its mask yields the network address; the mask 255.255.255.0, for example, marks the first 24 bits as the network portion and the last 8 bits as the host portion.

What does /24 mean in an IP address?

The /24 in CIDR notation means the first 24 of the address's 32 bits identify the network, equivalent to the subnet mask 255.255.255.0. The remaining 8 bits identify individual hosts within that network, giving 2⁸ = 256 total addresses, of which 254 are usable after reserving the network and broadcast addresses.

How do I find the network and broadcast address for 192.168.1.10/26?

A /26 mask is 255.255.255.192, leaving 6 host bits in the last octet and a block size of 2⁶ = 64 addresses. Since 10 falls within the 0-63 block, the network address is 192.168.1.0 (all host bits zeroed) and the broadcast address is 192.168.1.63 (all host bits set to 1); the usable host range is 192.168.1.1 through 192.168.1.62, or 62 addresses.

Why does subnetting exist?

Subnetting divides a large network into smaller, independently managed segments, which limits how far broadcast traffic spreads, isolates faults and unwanted traffic to a smaller portion of the network, and lets address space be allocated to roughly match actual device counts instead of wasting large blocks on small links. It also allows routers to aggregate many small subnets into fewer routing table entries, which is essential for scaling internet routing.

How many usable hosts are in a /26 network?

62. A /26 prefix leaves 6 host bits (32 − 26 = 6), giving 2⁶ = 64 total addresses in the subnet. Of those, the all-zeros address is reserved as the network address and the all-ones address is reserved as the broadcast address, leaving 2⁶ − 2 = 62 addresses that can be assigned to devices.

What is the difference between CIDR and the old classful addressing system?

Classful addressing fixed network size to one of a few rigid options (class A, B or C) based on the first bits of an address, which wasted large amounts of address space on organizations that needed something between the fixed sizes. CIDR, specified in RFC 4632, replaced this with variable-length prefixes written in slash notation (e.g. /24, /26), allowing a network to be sized to almost any power-of-two boundary and letting routers aggregate multiple networks into fewer routing table entries.

Fonti

  1. Mogul J, Postel J. Internet Standard Subnetting Procedure. RFC 950, IETF, 1985.
  2. Fuller V, Li T. Classless Inter-domain Routing (CIDR): The Internet Address Assignment and Aggregation Plan. RFC 4632, IETF, 2006.
  3. Postel J. Internet Protocol. RFC 791, IETF, 1981.
  4. Rekhter Y, Moskowitz B, Karrenberg D, de Groot GJ, Lear E. Address Allocation for Private Internets. RFC 1918, IETF, 1996.

Calcolatori correlati