Follow
Subscribe via Email!

Enter your email address to subscribe to this platform and receive notifications of new posts by email.

What is Subnetting and How Do Networks Divide IP Space?

Subnetting divides an IP network into smaller logical networks using subnet masks and CIDR prefixes, shaping IPv4 and IPv6 routing, firewall perimeters, and DNS geo-location.
Close-up of glowing blue fiber optic cables and data center hardware in a dark room.

Subnetting is the practice of dividing a single IP network into two or more smaller logical networks, called subnets. Explaining what is subnetting comes down to how a subnet mask or routing prefix splits an IP address into a shared network prefix and a unique host identifier, allowing routers to separate local traffic from remote destinations [1, 7]. Unlike Network Address Translation, which maps addresses between private and public networks at a boundary device, subnetting partitions an existing address block into smaller routed segments inside an organization or allocation space.

What Is Subnetting?

An IP address gives every device on a network two pieces of information: which network the machine sits on and which host interface it uses. Computers on the same subnet share an identical group of most-significant bits at the front of their addresses, forming the routing prefix. The trailing bits make up the host identifier, which stays unique to one local device or network interface [7].

When a host sends a packet, it checks whether the destination shares its own network prefix. If both addresses share that prefix, the packet travels directly across the local link, which may connect multiple physical Ethernet segments through network switches. If the prefixes differ, the host passes the packet to a designated default router, which acts as the logical or physical border between subnets and forwards traffic onward [7].

Modern networks write this split in Classless Inter-Domain Routing (CIDR) notation, appending a slash and the prefix bit length to the base network address. For example, the IPv4 block 198.51.100.0/24 uses 24 bits for the network prefix and reserves 8 bits for hosts, covering addresses from 198.51.100.0 through 198.51.100.255. Devices receive their address and prefix settings manually, from a Dynamic Host Configuration Protocol (DHCP) server, or through stateless address autoconfiguration [7].

Cisco network diagram of a misconfigured all-in-one subnet setup for subnetting access routers
Cisco topology illustrating how mismatched masks on an all-in-one subnet trigger broadcast routing loops between access routers. (Credit: Cisco)

Why Organizations Use Subnetting

In August 1985, J. C. Mogul and J. Postel outlined why campuses and multi-building companies needed a third level of address hierarchy in Internet Standard Subnetting Procedure (RFC 950). Early Internet addressing assumed a simple two-level split between the global Internet and individual networks, where each network looked like a “black box” to connected hosts. Many organizations still had to run more than one local area network (LAN) cable because of hardware limits on cable length and host counts, mixed technologies such as Ethernet and ring networks, high-bandwidth cliques of hosts congesting a shared cable, or point-to-point links bridging distant campus buildings [1].

Before adopting subnets, a multi-LAN site faced two awkward alternatives. Acquiring a separate Internet network number for every cable forced global routing tables to grow with local wiring details that outside gateways did not need. Assigning host numbers under one network without tracking which cable held each device—called “transparent subnets”—relied on bridges intercepting Address Resolution Protocol (ARP) broadcasts as described in RFC 925, but that broke down on non-broadcast links and swelled bridge caches as host counts rose [1].

Using “explicit subnets” let an organization keep one network number while partitioning its host bits across separate LANs, which slowed IP address depletion when paired with other tools and gave departments separate administrative control [1, 3, 7]. In real deployments, researchers later built tools to map these boundaries from outside, since Jean-François Grailet and Benoît Donnet noted in 2020 that traffic engineering policies complicate finding subnets—defined as “sets of devices located on the same connection medium”—prompting their linear-time inference tool WISE (Wide and lInear Subnet inferencE) [10].

Bitwise Masks and CIDR Prefixes

When drafting RFC 950, Mogul and Postel weighed five ways to encode subnet boundaries, including fixed-width fields and self-encoding bits that varied subnet sizes within a single address. They settled on a 32-bit bitmask—called an “address mask”—because it added no more implementation cost than a boolean flag while letting each network pick its own prefix length, making it “the most flexible scheme, yet costs no more” [1].

An IPv4 subnet mask places a continuous run of 1 bits on the left for the network prefix and trailing 0 bits on the right for the host identifier. Applying a bitwise AND operation between the IPv4 address 192.0.2.130 and the /24 mask 255.255.255.0 (four octets in dot-decimal notation) isolates the network prefix 192.0.2.0, while ANDing the address with the mask’s ones’ complement leaves the host number 130. Subnetting simply shifts high-order bits from the host side to the prefix side by extending the mask’s ones [7].

CDN Planet diagram showing a CDN with edns-client-subnet support
Authoritative DNS servers using edns-client-subnet data to direct clients to a nearby CDN edge server. (Credit: CDN Planet)

Before CIDR (RFC 4632) arrived, IPv4 used classful networking, where the highest-order bits of an address fixed its Class A, B, or C mask automatically. Today, assigning an IPv4 address requires passing both the address and its netmask to the interface, though some implementations still fall back to classful defaults if the mask is omitted [2, 7]. While every connected subnet adds a route entry to local routers, tree-like hierarchies let distant routers aggregate collections of adjacent subnets into a single supernetwork route [7].

Counting Subnets and Usable Hosts

Subnet math follows two powers-of-two rules based on how many bits belong to the subnet field (n) and the host field (h). Borrowing n bits from the host portion creates 2n subnets, and each subnet holds 2h − 2 usable host addresses because the lowest all-zeros host value names the subnet itself and the highest all-ones value acts as its broadcast address [7].

A /24 block such as 192.168.5.0/24 shows how that split plays out when two host bits move into the prefix. Extending the mask from 24 bits to 26 bits (255.255.255.192) yields four /26 subnets, each leaving 6 bits for hosts and supplying 62 usable host addresses (26 − 2). One exception exists for 31-bit masks on point-to-point links, where a single host bit provides two endpoint addresses without needing separate network and broadcast identifiers [7].

Larger blocks scale the same way when engineers carve up enterprise space. By default, a Class B network such as 172.16.0.0/16 reserves 16 bits for hosts and allows 65,534 valid host addresses (216 − 2). Borrowing 3 host bits creates eight /19 subnets using mask 255.255.224.0, starting with 172.16.0.0 (usable hosts 172.16.0.1 to 172.16.31.254, broadcast 172.16.31.255) and stepping by 32 in the third octet up to 172.16.224.0 (usable hosts 172.16.224.1 to 172.16.255.254, broadcast 172.16.255.255) [3].

CDN Planet diagram showing a CDN without edns-client-subnet support
DNS resolution without edns-client-subnet support when a client uses a distant public recursive resolver. (Credit: CDN Planet)

Subnet Zero vs. All-Ones Subnets

In 1985, RFC 950 advised engineers not to assign the first subnet (all zeros in the subnet bits, called subnet zero) or the last subnet (all ones, called the all-ones subnet) to real links [1, 3]. In the 172.16.0.0/16 example split into /19 blocks, subnet zero shares the exact network address 172.16.0.0 with the unsplit parent block, and the all-ones subnet 172.16.224.0/19 shares the broadcast address 172.16.255.255 with the parent network. Skipping both reduced eight possible /19 subnets to six (23 − 2) [3].

The IETF declared that restriction obsolete in 1995, and modern CIDR systems treat all subdivided blocks—such as all sixteen /28 subnets inside a /24—as usable [7]. On Cisco hardware, routers older than Cisco IOS Software Release 12.0 blocked subnet zero by default unless an administrator entered ip subnet-zero (or service subnet-zero before Release 8.3), whereas Release 12.0 enabled it by default and RFC 1878 documented the shift [3].

Even when routers permit all subnets, mismatched masks on hosts still cause failures. Cisco engineers illustrated a lab setup where Router 1 splits 192.168.1.0/24 into four /26 pieces across Routers 2 through 5 for incoming asynchronous lines. If host 192.168.1.24 is given a 255.255.255.0 mask instead of 255.255.255.192 and sends a NetBIOS or WINS broadcast to 192.168.1.255, Router 2 forwards it to Router 1, which sends it to Router 5 (which owns 192.168.1.192/26), starting a routing loop between Router 1 and Router 5 until TTL expires. Fixing host masks stops the loop, and Cisco advises routing 192.168.1.255 to a loopback interface rather than Null0, which generates ICMP unreachable traffic, even on high-capacity hardware like a Cisco 7513 [3].

CDN Planet diagram showing a CDN with Anycast for HTTP
HTTP Anycast routing directing user traffic to the closest CDN server without DNS geo-targeting. (Credit: CDN Planet)

IPv6 Subnetting vs. IPv4 Models

IPv6 uses 128-bit addresses instead of 32-bit addresses and saw growing deployment around 2006. Because its address pool is vast, IPv6 subnetting focuses on routing hierarchy rather than saving scarce addresses, using variable-length subnet masking (VLSM) and CIDR while keeping a standard /64 routing prefix with 64 bits for host identifiers on compliant subnets. For example, the documentation block 2001:db8::/32 allocates 32 bits to the prefix and leaves the remaining 96 bits for subnets and hosts [7].

In July 2010, H. Singh, W. Beebee of Cisco Systems, and E. Nordmark of Oracle explained in RFC 5942 that mixing up IPv4 and IPv6 rules caused “incorrect implementations that do not interoperate”. An IPv4 interface ties a netmask directly to an address to mark which destinations sit on-link, but Neighbor Discovery (RFC 4861) keeps IPv6 address assignment and on-link status separate. By default, an IPv6 host treats only the link-local prefix as on-link and assumes every other destination is off-link unless told otherwise [2].

Hosts learn on-link IPv6 prefixes into their Prefix List from manual /128 or prefix settings or from Router Advertisements carrying the L-bit with a non-zero lifetime, while Redirect messages can mark single targets on-link in the Destination Cache. When the Default Router List is empty, RFC 4861 requires sending an ICMPv6 Destination Unreachable message rather than assuming destinations are on-link as older RFC 2461 did. For security, RFC 5942 also removed two imprecise RFC 4861 rules that treated an address as on-link just because a Neighbor Advertisement or Neighbor Discovery packet arrived from it [2].

Screened Subnets in Firewall Design

Beyond routing and address planning, subnet boundaries isolate exposed servers from trusted internal machines. In the 2002 second edition of Building Internet Firewalls, Elizabeth D. Zwicky, Simon Cooper, and D. Brent Chapman describe a screened subnet architecture that places a perimeter network—often called a demilitarized zone (DMZ)—between an exterior access router and an interior choke router [5, 9]. Organizations running e-commerce or web services use this three-subnet layout against worms, botnets, and intruders, either with two separate routers or a single firewall holding three interfaces [9].

A perimeter subnet matters because a publicly reachable bastion host running HTTP, FTP, or SMTP proxies is the likeliest machine to be compromised. On shared media like Ethernet, token ring, or FDDI, any compromised machine can snoop on passwords and files moving across that same segment—an effect Zwicky and her coauthors likened to looking “watch over the shoulder” of users. Placing the bastion host on its own perimeter subnet stops a breach from becoming an “instantaneous jackpot” because purely internal traffic never crosses that wire, leaving “no single vulnerable point” if the interior router blocks unnecessary ports to internal mail or DNS servers [5].

CDN Planet diagram showing a CDN without edns-client-subnet support using a normal ISP resolver
DNS lookup routed through an ISP resolver without edns-client-subnet when the resolver sits near the user. (Credit: CDN Planet)

Splitting the firewall across two routers also cuts per-router filtering load compared with a screened host firewall, which uses only one router and leaves internal systems directly exposed to a breached bastion host. On the outer boundary, the exterior router—often managed by an ISP—can block incoming packets with forged internal source addresses and drop outbound packets carrying invalid source addresses, while marketing usage sometimes blurs “DMZ” and “screened subnet” even when vendors place hosts behind only one border router [5, 9].

EDNS Client Subnet in DNS

Subnets also guide content delivery networks (CDNs) when recursive DNS resolvers sit far from end users. In August 2011, Google Public DNS and OpenDNS implemented EDNS Client Subnet (ECS)—later standardized in RFC 7871—as part of the Global Internet Speedup initiative so resolvers could forward a client’s partial IP subnet to authoritative DNS servers [4, 6, 8]. Without ECS, a user in Brazil querying OpenDNS in Florida or a user in Thailand hitting OpenDNS in Singapore could get routed to a distant CDN edge server instead of a local cache [6]. Some CDNs avoid DNS geo-targeting altogether by using HTTP anycast, which directs users to nearby servers via BGP routing paths.

Google for Developers warned in September 2024 that inconsistent authoritative setups break ECS auto-detection. If one name server for an ECS-enabled zone omits ECS, its global /0 responses fill resolver caches and override geo-located answers. Servers must echo matching ECS fields across A, AAAA, PTR, MX, and error replies—using global /0 scope for NXDOMAIN, NODATA, SOA, NS, DS, and delegations—and never return overlapping scope prefixes such as 198.0.0.0/8 alongside 198.51.0.0/16 [4].

Testing ECS support with a patched dig 9.10 client against Edgecast and Google’s 8.8.8.8 in October 2012 showed responses scoped to 58.8.96.26/14, though providers like Akamai restrict ECS to allowlisted resolvers [6, 8]. Privacy remains contested because transit networks and upstream servers see partial client subnets, prompting Cloudflare CEO Matthew Prince to keep ECS disabled on 1.1.1.1—a stance that led Archive.today to block Cloudflare DNS queries [8].

Sources
  1. REPORT Mogul, J., & Postel, J. (1985). Internet Standard Subnetting Procedure (RFC 950). Network Working Group. [Article Link]
  2. REPORT Singh, H., Beebee, W., & Nordmark, E. (2010). IPv6 Subnet Model: The Relationship between Links and Subnet Prefixes (RFC 5942). Internet Engineering Task Force. [Article Link]
  3. WEBSITE Cisco Engineers. (2023, February 7). Configure Subnet Zero and All-Ones Subnet. Cisco. [Article Link]
  4. WEBSITE Google for Developers. (2024, September 3). EDNS Client Subnet (ECS) Guidelines. [Article Link]
  5. BOOK CHAPTER Zwicky, E. D., Cooper, S., & Chapman, D. B. (2002). Screened subnet architectures. In Building Internet Firewalls (2nd ed., Section 6.3). O’Reilly & Associates. [Article Link]
  6. WEBSITE Sajal. (2012, October 17). Which CDNs support edns-client-subnet? CDN Planet. [Article Link]
  7. WEBSITE Wikipedia. (n.d.). Subnet. [Article Link]
  8. WEBSITE Wikipedia. (n.d.). EDNS Client Subnet. [Article Link]
  9. WEBSITE Wikipedia. (n.d.). Screened subnet. [Article Link]
  10. ACADEMIC JOURNAL Grailet, J., & Donnet, B. (2020). Virtual Insanity: Linear Subnet Discovery. IEEE Transactions on Network and Service Management, 17(2), 1268-1281. [Article Link]

Cover image: Manmakro / Wikimedia Commons, CC BY-SA 4.0

Leave a Comment

Related Posts
Total
0
Share