Subnet
A block of IP addresses that share a common prefix, written in CIDR notation such as 192.168.1.0/24, which decides what a device can reach directly and what it must send through a router.
A subnet is a contiguous block of IP addresses that share the same leading bits, the prefix. Every IP address splits into a network part, which identifies the subnet, and a host part, which identifies a device within it. Devices on the same subnet talk to each other directly. Traffic for anywhere else goes to a default gateway, the router.
CIDR notation writes a subnet as an address and a prefix length: 192.168.1.0/24 means the first 24 of the 32 bits are fixed, leaving 8 bits, or 256 addresses, for hosts. Two of those are reserved, the all-zeros network address and the all-ones broadcast address, so 254 are usable. The older subnet mask says the same thing in dotted form: /24 is 255.255.255.0.
CIDR (Classless Inter-Domain Routing, 1993) replaced classful addressing, which handed out only three sizes: class A networks of 16 million addresses, class B of 65,536 and class C of 256. An organization needing 300 addresses had to take a class B and waste most of it. Variable-length prefixes allowed blocks sized to need and slowed IPv4 exhaustion.
Prefixes also make routing scale:
- Longest-prefix match. A router's table maps prefixes to next hops, and a packet follows the most specific matching entry. Routers do this lookup with structures related to the Trie, in specialized hardware.
- Aggregation. An ISP holding
198.51.0.0/16can announce that single prefix to the rest of the internet instead of thousands of customer routes, which keeps the global Border Gateway Protocol table manageable.
On a local network, DHCP (Dynamic Host Configuration Protocol) hands each joining device an address from the subnet's pool, along with the mask, the gateway and the DNS servers. Addresses are leased for a limited time and renewed while the device stays. Within the subnet, devices find each other's hardware addresses by broadcasting ARP queries, which is why broadcasts and Multicast usually stay within one subnet.
Subnets are also a security boundary. Separating cameras, guests and servers into their own subnets, with a Firewall between them, limits what a compromised device can reach, an application of Least Privilege. Zero Trust Network designs go further and stop treating any subnet as trusted.
Common trouble spots:
- Overlapping ranges. Two networks both using
192.168.1.0/24can't be joined by a Virtual Private Network without renumbering or translation. - Running out. A
/24for a growing office or cloud network fills up, and resizing a subnet means changing every device's addressing. - Private ranges behind Network Address Translation hide the subnet layout from the outside but make inbound access harder.
IPv6 uses the same notation with a standard /64 per subnet, which holds more addresses than the entire IPv4 internet, so subnets there are never sized by scarcity.
See also2
Loopback
The network address a computer uses to talk to itself, where packets go out and come straight back without touching any hardware, the home of development servers and a recurring blind spot in security.
Networks & Distribution12 connections
Multicast DNS
How devices on a local network find each other by name, and discover printers, speakers, and screens, without any server or configuration, by asking everyone at once.
Networks & Distribution8 connections
Linked from7
- EthernetNetworks & Distribution
The wired local networking standard that carries most of the world's traffic over its first hop, from the frame format and MAC addresses to switches, ARP, and power over the same cable.
- IPv6Networks & Distribution
IPv6 exists mainly to end address scarcity, with a large enough space that per-device NAT becomes optional.
- MulticastNetworks & Distribution
Multicast sends one stream to a group of subscribed receivers at once, letting the network fan it out instead of the sender.
- Multicast DNSNetworks & Distribution
How devices on a local network find each other by name, and discover printers, speakers, and screens, without any server or configuration, by asking everyone at once.
- Network Address TranslationNetworks & Distribution
Rewriting the addresses in packets as they cross a router so that many devices can share one public IPv4 address, a stopgap that became permanent and broke the internet's end-to-end design.
- TrieComputation & Algorithms
A tree that stores strings by shared prefix, so each node represents a prefix all its descendants extend.
- Wi-FiNetworks & Distribution
Wireless local networking over shared, unlicensed radio channels, where every device on a channel takes turns talking, which explains most of its speed, range, and reliability quirks.