AlgoInsight

Free lesson · Computer Networking

Ipv4 Address Classes And Ranges

Easy10 min readnetworkingcomputer-networkstcp-ip

The Original System for Organizing IP Addresses

When the IPv4 address space was designed in the early 1980s, the internet's architects needed a way to allocate addresses to organizations of different sizes. A university with thousands of computers needed more addresses than a small business with ten. The solution was classful addressing - dividing the entire IPv4 address space into five classes (A through E) with different ratios of network addresses to host addresses.

Understanding classful addressing matters for two reasons. First, it explains the private address ranges you use daily (10.x.x.x, 172.16.x.x, 192.168.x.x) - each comes from a different class and has a different size because of how classful addressing divided the space. Second, interview questions and networking documentation still reference classes, even though modern networking has replaced classful addressing with CIDR (Classless Inter-Domain Routing), which you will learn in Topic 3.

The classful system is historically important but practically obsolete. CIDR replaced it in 1993 because classful addressing wasted enormous amounts of address space. But the vocabulary persists - you will still hear people say "Class C network" or "Class A private range" in networking conversations, and understanding what they mean requires knowing the original classification.

The Five Classes

The class of an IPv4 address is determined by the first few bits of the address. You can also identify the class by looking at the first octet (the first decimal number in the dotted notation).

Class A - Large Networks

First octet range: 1–126 First bit pattern: Starts with 0 Default subnet mask: 255.0.0.0 (/8) Network portion: First 8 bits (1 octet) Host portion: Last 24 bits (3 octets) Number of networks: 126 Hosts per network: 16,777,214

Class A was designed for very large organizations. With 24 bits for host addresses, each Class A network can accommodate over 16 million devices. Only 126 Class A networks exist, and they were originally allocated to massive entities - IBM, AT&T, the US Department of Defense, Apple, Ford Motor Company, and similar organizations.

The waste in Class A is immediately obvious: very few organizations actually have 16 million devices on a single network. An organization with 50,000 devices allocated a Class A network is using 0.3% of its address space and wasting the remaining 16.7 million addresses. Even today, organizations holding Class A allocations from the early internet (like Apple, which holds 17.0.0.0/8, or Ford Motor Company, which holds 19.0.0.0/8) control address blocks worth hundreds of millions of dollars at current market prices. Some have returned or sold portions of their allocations as IPv4 scarcity has increased the economic incentive to do so. This waste was one of the primary drivers behind CIDR's creation.

Class B - Medium Networks

First octet range: 128–191 First bit pattern: Starts with 10 Default subnet mask: 255.255.0.0 (/16) Network portion: First 16 bits (2 octets) Host portion: Last 16 bits (2 octets) Number of networks: 16,384 Hosts per network: 65,534

Class B was designed for medium-sized organizations - universities, large companies, government agencies. Each Class B network supports about 65,000 hosts. This was a better fit for many organizations, but the allocation was still coarse: an organization with 300 devices allocated a Class B network was wasting over 65,000 addresses.

Class C - Small Networks

First octet range: 192–223 First bit pattern: Starts with 110 Default subnet mask: 255.255.0.0 (/24) Network portion: First 24 bits (3 octets) Host portion: Last 8 bits (1 octet) Number of networks: 2,097,152 Hosts per network: 254

Class C was designed for small organizations. With only 8 bits for host addresses, each Class C network supports at most 254 devices (256 total addresses minus 2: one reserved for the network address and one for the broadcast address). There are over 2 million Class C networks, making them the most numerous class.

The problem with Class C was the opposite of Class A: for many organizations, 254 hosts was not enough, but jumping to a Class B with 65,534 hosts was massive overkill. There was no clean way to get, say, 1,000 addresses without either being allocated four Class C blocks (and dealing with routing complexity) or being allocated one Class B block (and wasting 64,534 addresses).

Class D - Multicast

First octet range: 224–239 First bit pattern: Starts with 1110 Purpose: Multicast group addresses

Class D addresses are not assigned to individual devices. They identify multicast groups - sets of devices that have opted to receive traffic sent to a specific multicast address. When a device sends a packet to a Class D address, it is delivered to all members of that multicast group. Video streaming, IPTV, routing protocol updates, and network discovery protocols use multicast.

Class E - Reserved / Experimental

First octet range: 240–255 First bit pattern: Starts with 1111 Purpose: Reserved for future use and experimental purposes

Class E addresses were never allocated for general use. They remain reserved. The address 255.255.255.255 (within this range) is the limited broadcast address used for broadcasting within a local network.

graph TD
    subgraph Classes["IPv4 Address Classes"]
        direction TB
        CA["Class A<br/>1.0.0.0 – 126.255.255.255<br/>Mask: /8<br/>16M hosts per network"]
        CB["Class B<br/>128.0.0.0 – 191.255.255.255<br/>Mask: /16<br/>65K hosts per network"]
        CC["Class C<br/>192.0.0.0 – 223.255.255.255<br/>Mask: /24<br/>254 hosts per network"]
        CD["Class D<br/>224.0.0.0 – 239.255.255.255<br/>Multicast"]
        CE["Class E<br/>240.0.0.0 – 255.255.255.255<br/>Reserved"]
    end

    style CA fill:#4f46e5,stroke:#4338ca,color:#fff
    style CB fill:#7c3aed,stroke:#6d28d9,color:#fff
    style CC fill:#8b5cf6,stroke:#7c3aed,color:#fff
    style CD fill:#a78bfa,stroke:#8b5cf6,color:#fff
    style CE fill:#c4b5fd,stroke:#a78bfa,color:#000
This diagram shows the five IPv4 address classes arranged vertically. Class A covers addresses from 1 to 126 in the first octet with a /8 mask and 16 million hosts per network. Class B covers 128 to 191 with a /16 mask and 65 thousand hosts per network. Class C covers 192 to 223 with a /24 mask and 254 hosts per network. Class D covers 224 to 239 and is used for multicast. Class E covers 240 to 255 and is reserved for experimental use.

Reserved and Special Ranges

Within the classful address space, several ranges are reserved for specific purposes. These are the addresses you encounter most frequently in practice.

Private Address Ranges (RFC 1918)

Three ranges are reserved for private use - they are not routable on the public internet and can be freely used within any private network:

Range Class CIDR Addresses Common Use
10.0.0.0 – 10.255.255.255 A 10.0.0.0/8 16,777,216 Cloud VPCs (AWS, GCP, Azure), large enterprise networks
172.16.0.0 – 172.31.255.255 B 172.16.0.0/12 1,048,576 Medium enterprise networks, Docker default bridge
192.168.0.0 – 192.168.255.255 C 192.168.0.0/16 65,536 Home networks, small office networks

Every time you connect to a Wi-Fi network and get an address like 192.168.1.15, you are using a private Class C address. Every time you provision a VPC in AWS with a CIDR block of 10.0.0.0/16, you are carving a subnet out of the private Class A range.

The reason three separate private ranges exist (instead of just one large range) is historical - each was carved from a different address class to give network administrators flexibility in choosing a range that matched their classful subnet mask conventions. In practice, the 10.x.x.x range is used most often in large environments because it provides the most address space.

Loopback Range

127.0.0.0/8 - the entire block of 16 million addresses starting with 127 is reserved for loopback. Traffic sent to any address in this range is delivered back to the sending device itself, never touching the physical network. In practice, 127.0.0.1 is almost universally used as the loopback address. The hostname localhost typically resolves to 127.0.0.1.

Developers use the loopback address constantly: running a web server on localhost:3000, connecting to a local database on 127.0.0.1:5432, testing API endpoints locally before deploying. Understanding that 127.0.0.1 is a loopback address (not a real network interface) explains why services bound to 127.0.0.1 are not accessible from other machines - the traffic never leaves the host.

Tip: A common debugging mistake: binding a server to 127.0.0.1 (localhost only) when you want it accessible from other machines on the network. To accept connections from any interface, bind to 0.0.0.0. To accept only local connections, bind to 127.0.0.1. In Docker containers, this distinction is critical - a server bound to 127.0.0.1 inside a container is not reachable from outside the container, even with port mapping.

Link-Local Range

169.254.0.0/16 - Automatic Private IP Addressing (APIPA). When a device is configured to use DHCP but cannot reach a DHCP server, it automatically assigns itself an address from this range using a process called link-local address autoconfiguration. The device picks a random address in the 169.254.1.0 to 169.254.254.255 range, sends an ARP probe to check if the address is already in use, and if no conflict is detected, assigns itself the address.

If you see a 169.254.x.x address on your device, it means DHCP is failing - which could be a problem with the DHCP server, the network connection, or a misconfigured network interface. The link-local address provides basic local connectivity (devices on the same link can communicate), but no internet access is possible because link-local addresses are not routable.

In cloud environments, the specific address 169.254.169.254 has a special role: it is the instance metadata service endpoint. AWS, GCP, and Azure all use this link-local address for instance metadata queries. When your application running on an EC2 instance sends an HTTP request to http://169.254.169.254/latest/meta-data/, it reaches a service provided by the hypervisor that returns information about the instance - its instance ID, region, IAM role credentials, and other metadata. This is a commonly used pattern in cloud-native applications for discovering runtime configuration.

Carrier-Grade NAT Range

100.64.0.0/10 - Reserved by RFC 6598 for Carrier-Grade NAT (CGNAT). This range is used by ISPs that assign private addresses to customers instead of public IPv4 addresses, performing NAT at the ISP level. This is distinct from the RFC 1918 private ranges and was created specifically to avoid conflicts when ISP-level NAT and customer-level NAT both operate on the same traffic path.

Documentation and Test Range

192.0.2.0/24, 198.51.100.0/24, and 203.0.113.0/24 - these three /24 blocks are reserved for use in documentation and examples. When you see an IP address in a textbook, tutorial, or RFC, it often uses one of these ranges to avoid accidentally referencing a real server. This course uses these ranges in some examples for the same reason.

Why Classful Addressing Failed

The classful system had a fundamental and ultimately fatal problem: the gap between class sizes was too large. A Class C network provides 254 hosts. The next step up, a Class B network, provides 65,534 hosts - a 258x jump. There was no class that provided, say, 2,000 or 10,000 addresses. An organization needing 500 addresses had two bad options: take two Class C networks (requiring routing complexity) or take one Class B network (wasting 65,000 addresses).

This inflexibility led to massive waste. Organizations were allocated far more addresses than they needed, and large portions of the IPv4 address space sat unused but claimed. By the early 1990s, it was clear that the internet would run out of addresses far sooner than the theoretical 4.3 billion limit suggested, because classful allocation was consuming addresses at a rate that far outpaced actual usage.

CIDR (Classless Inter-Domain Routing), introduced in 1993 via RFC 1519, solved this by eliminating fixed class boundaries. Instead of rigid /8, /16, and /24 divisions, CIDR allows subnet masks at any bit boundary - /20, /22, /27, or any other prefix length. This means an organization needing 500 addresses can be allocated a /23 (512 addresses) instead of a /16 (65,536 addresses). CIDR reduced waste by over 99% compared to classful allocation for typical organizations and is the addressing system used universally today.

You will learn CIDR notation and subnetting calculations in depth in the next two topics.

graph LR
    subgraph Classful["Classful: Fixed Sizes"]
        direction TB
        CF_C["/24 - 254 hosts"]
        CF_B["/16 - 65,534 hosts"]
        CF_A["/8 - 16.7M hosts"]
        CF_GAP["258x gap between<br/>Class C and Class B!"]
    end

    subgraph CIDR["CIDR: Flexible Sizes"]
        direction TB
        CI_27["/27 - 30 hosts"]
        CI_24["/24 - 254 hosts"]
        CI_22["/22 - 1,022 hosts"]
        CI_20["/20 - 4,094 hosts"]
        CI_16["/16 - 65,534 hosts"]
        CI_FLEX["Any size you need"]
    end

    style CF_C fill:#a78bfa,stroke:#8b5cf6,color:#fff
    style CF_B fill:#a78bfa,stroke:#8b5cf6,color:#fff
    style CF_A fill:#a78bfa,stroke:#8b5cf6,color:#fff
    style CF_GAP fill:#ef4444,stroke:#dc2626,color:#fff
    style CI_27 fill:#4f46e5,stroke:#4338ca,color:#fff
    style CI_24 fill:#4f46e5,stroke:#4338ca,color:#fff
    style CI_22 fill:#4f46e5,stroke:#4338ca,color:#fff
    style CI_20 fill:#4f46e5,stroke:#4338ca,color:#fff
    style CI_16 fill:#4f46e5,stroke:#4338ca,color:#fff
    style CI_FLEX fill:#22c55e,stroke:#16a34a,color:#fff
This diagram contrasts classful addressing with CIDR. On the left, classful addressing offers only three fixed sizes: /24 with 254 hosts, /16 with 65,534 hosts, and /8 with 16.7 million hosts. A red box highlights the 258 times gap between Class C and Class B. On the right, CIDR offers flexible sizes at any prefix length: /27 with 30 hosts, /24 with 254 hosts, /22 with 1,022 hosts, /20 with 4,094 hosts, /16 with 65,534 hosts, and any other size needed. A green box says any size you need.

Interview: Address classes rarely appear directly in System Design interviews, but the private ranges and special addresses come up constantly:

"What CIDR block would you use for a VPC?" - Typically 10.0.0.0/16 (65,536 addresses from the Class A private range), subdivided into /24 subnets for different tiers (public, private, database). Knowing why you are choosing from the 10.x.x.x range and how many addresses it provides demonstrates networking fluency.

"What is 127.0.0.1?" - It is the loopback address. Services bound to it are only accessible locally. This comes up in debugging discussions when services cannot communicate across containers or VMs.

"Why does my service work locally but not in production?" - Often because the service is bound to 127.0.0.1 instead of 0.0.0.0, or because the production network uses a different private IP range, or because NAT or security group rules are blocking traffic. Understanding IP address types helps narrow the diagnosis.

What Comes Next

The next topic - Subnetting - is the most practically important networking skill in this module. Subnetting takes the classless approach (CIDR) and shows you how to divide a network into smaller sub-networks, calculate how many hosts each subnet can hold, and design IP address schemes for real infrastructure.

Exercise: Starter: Identify the class of each of these IP addresses: 8.8.8.8, 172.217.14.206, 192.168.0.1, 224.0.0.1, 10.0.3.15. For each, state whether it is a public or private address. What class does each belong to?

Intermediate: Your company has been allocated the public IP range 198.51.100.0/24 (a documentation range used for this exercise). How many usable host addresses does this provide? If you need to serve 200 web servers with public IPs, is this /24 block sufficient? If you also need addresses for load balancers, NAT gateways, and DNS servers, how would you allocate addresses within this block?

Advanced: Research how Carrier-Grade NAT (CGNAT) works. ISPs increasingly assign private addresses (from the 100.64.0.0/10 range, reserved for CGNAT by RFC 6598) to customers instead of public addresses, then perform NAT at the ISP level. How does this differ from home NAT? What problems does CGNAT cause for peer-to-peer applications, gaming, and running servers from home? Why are ISPs using CGNAT despite these drawbacks?

Back to Computer Networking