Skip to content
Home
IP Addressing: IPv4, IPv6 Subnetting, and CIDR Explained

IP Addressing: IPv4, IPv6 Subnetting, and CIDR Explained

Computer Networking Computer Networking 8 min read 1694 words Beginner ExcellentWiki Editorial Team

IP addressing provides the logical identification scheme that enables devices to find and communicate with each other across interconnected networks. Every interface on a network requires a unique IP address. The transition from IPv4 — which has powered the internet since the early 1980s — to IPv6 is one of the most significant infrastructure shifts in networking history. This guide covers IPv4 structure and subnetting, IPv6 addressing and autoconfiguration, CIDR notation, VLSM, NAT, and operational planning.

IPv4 Addressing

IPv4 uses 32-bit addresses, theoretically providing approximately 4.3 billion unique addresses. Addresses are expressed in dotted-decimal notation: four octets separated by periods, each ranging from 0 to 255. The original internet architects assumed 4.3 billion addresses would be sufficient; the explosion of consumer devices, mobile phones, and IoT sensors proved otherwise. IANA allocated the last remaining IPv4 /8 block in 2011, and regional registries (ARIN, RIPE NCC, APNIC, LACNIC, AFRINIC) have exhausted their pools since.

Address Classes and CIDR

Historically, IPv4 was divided into fixed-size classes: Class A (first octet 1–126, 16 million hosts per network), Class B (128–191, 65,534 hosts), Class C (192–223, 254 hosts), Class D (224–239, multicast), and Class E (240–255, reserved). Classful addressing wasted enormous address space — a /16 network (class B) with 100 hosts wasted 65,434 addresses. Classless Inter-Domain Routing (RFC 1518, 1519), introduced in 1993, replaced classes with variable-length subnet masks and prefixes such as /24, /27, or /30, enabling efficient address allocation. CIDR notation appends the prefix length to the address: 192.168.1.0/24 indicates 24 network bits and 8 host bits.

Private Address Space

RFC 1918 reserved three ranges for private (non-internet-routable) networks: 10.0.0.0/8 (16 million addresses), 172.16.0.0/12 (1 million addresses), and 192.168.0.0/16 (65,536 addresses). Private addresses are reused within organizations; NAT translates them to public addresses for internet access. Carrier-grade NAT (CGNAT, RFC 6598) adds the 100.64.0.0/10 space for ISPs that have exhausted their public pools.

Special-Purpose Addresses

127.0.0.0/8 is loopback — packets sent to this address are processed by the local network stack without leaving the host. 0.0.0.0/0 represents the default route. 169.254.0.0/16 is link-local (APIPA), automatically assigned when DHCP fails. 224.0.0.0/4 is multicast (group communication). 240.0.0.0/4 is reserved for future use (RFC 1112).

Subnetting and VLSM

Subnetting divides a network prefix into smaller segments. Each subnet has its own network address, broadcast address, and host range. The subnet mask (or prefix length) determines the boundary — for example, 255.255.255.192 (or /26) divides a /24 into four subnets of 62 usable hosts each.

Variable-Length Subnet Masks

VLSM allows different subnets within the same network to use different prefix lengths. A /24 can be carved into a /28 (14 hosts) for a small department, a /26 (62 hosts) for a medium team, and a /30 (2 hosts) for a point-to-point link. VLSM eliminates the waste of applying one subnet size to all segments. Route summarization (aggregation) is the inverse: multiple contiguous prefixes are advertised as a single larger prefix, reducing routing table size.

Subnet Calculation Examples

A /27 (mask 255.255.255.224) yields 32 addresses per subnet, 30 usable. The first subnet of 10.1.1.0/27 uses network address 10.1.1.0, hosts 10.1.1.1–10.1.1.30, and broadcast 10.1.1.31. The next subnet starts at 10.1.1.32/27. For point-to-point links, /31 (RFC 3021) eliminates the broadcast address and the .0 network address restriction, yielding 2 usable addresses instead of wasting a /30’s 2-of-4.

Network Address Translation

NAT (RFC 2663) maps multiple private addresses to one or more public addresses. The most common form, port address translation (PAT), uses unique TCP/UDP port numbers for each translation entry. A home router with one public IP can support dozens of devices simultaneously by maintaining a translation table. NAT conserves IPv4 address space but breaks the end-to-end principle (RFC 2775): unsolicited inbound connections to NAT’d devices are impossible without explicit port forwarding or UPnP. IPv6, with its vast address space, eliminates the need for NAT entirely.

IPv6 Addressing

IPv6 (RFC 8200) uses 128-bit addresses, providing approximately 340 undecillion addresses — roughly 10^29 addresses per person on earth. Addresses are written as eight groups of four hexadecimal digits separated by colons, e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Leading zeros can be omitted. A double colon (::) replaces the longest contiguous string of all-zero groups but may appear only once per address.

IPv6 Address Types

Unicast addresses identify a single interface. Multicast addresses (prefix ff00::/8) replace IPv4 broadcast — traffic is delivered to all subscribed interfaces. Anycast addresses are assigned to multiple interfaces; packets are routed to the nearest one. There is no broadcast in IPv6.

IPv6 Address Scopes

Link-local addresses (fe80::/10) are automatically generated on every interface and are only reachable within the same layer-2 domain. Link-local addresses are never routed. Unique local addresses (fc00::/7) are analogous to RFC 1918 private addresses — routable within a site but not on the global internet. Global unicast addresses (2000::/3) are globally routable, equivalent to public IPv4 addresses.

Stateless Address Autoconfiguration

SLAAC (RFC 4862) enables a device to generate its own IPv6 address without a DHCP server. The device listens for Router Advertisement messages (ICMPv6 type 134) sent by the local router. The RA contains the network prefix. The device appends a 64-bit interface identifier (IID) to form a complete address. The IID was traditionally derived from the MAC address (EUI-64), but privacy extensions (RFC 4941, RFC 8981) generate temporary random IIDs to prevent device tracking by the address.

DHCPv6

DHCPv6 (RFC 8415) provides stateful address assignment and configuration parameter delivery (DNS server, domain search list). In the stateless operation mode, devices use SLAAC for addressing but request DNS and other parameters from DHCPv6. In stateful mode, DHCPv6 assigns both the address and the parameters — analogous to IPv4 DHCP but with a different message format and transport (UDP on 546/547).

Transition Technologies

The transition from IPv4 to IPv6 is a multi-decade process requiring coexistence. Dual-stack runs IPv4 and IPv6 simultaneously on every interface — the preferred approach. Tunneling (6to4, Teredo, GRE) encapsulates IPv6 packets inside IPv4 headers. Translation (NAT64, DNS64) maps IPv6-only client traffic to IPv4-only servers at a gateway. Most major cloud providers (AWS, GCP, Azure) have completed dual-stack enablement, and the IETF recommends dual-stack in new deployments.

IP Address Management

Structured IP address management prevents conflicts and simplifies operations. An IPAM system — whether text-based spreadsheets, a dedicated solution like phpIPAM or NetBox, or a vendor platform — must track the allocated subnets, utilization percentages, assigned host addresses, and DNS records. Documentation standards: each subnet record should include network address, mask/default route, DHCP scope, VLAN ID, purpose, and administrator contact.

FAQ

Q: What is the difference between a subnet mask in IPv4 and a prefix length in CIDR?
A: They represent the same boundary in different notation. The subnet mask 255.255.255.0 in binary has 24 consecutive 1s; the CIDR prefix length /24 writes that as “slash 24.” CIDR notation is more compact and frees subnet masks from the classful convention.

Q: Do I need NAT if I use IPv6?
A: No. IPv6 provides enough address space for every interface to have a globally routable address. NAT in IPv4 exists to conserve scarce address space. The end-to-end connectivity model is restored with IPv6 — any device can initiate a direct connection to any other device without address translation.

Q: How do I calculate subnet hosts from a prefix length?
A: The number of addresses in a subnet = 2^(32 - prefix length). Subtract 2 for the network and broadcast addresses (unless using /31 for point-to-point). For a /26: 2^(32-26) = 64 addresses, 62 usable.

Q: What is the difference between SLAAC and DHCPv6?
A: SLAAC provides autonomous address configuration using router advertisements. DHCPv6 provides address configuration and/or parameter delivery from a server. Stateless DHCPv6 uses SLAAC for addresses and DHCPv6 only for parameters. Stateful DHCPv6 uses DHCPv6 for both.

Q: Why is RFC 1918 address space reused?
A: Private addresses are not globally unique — they are only meaningful within a single administrative domain. Two organizations can both use 10.0.0.0/8 without conflict because these addresses are translated or filtered at their network boundaries.

Internal Links

References

  • RFC 791, “Internet Protocol”
  • RFC 1918, “Address Allocation for Private Internets”
  • RFC 4632, “Classless Inter-domain Routing (CIDR)”
  • RFC 8200, “Internet Protocol, Version 6 (IPv6) Specification”
  • RFC 4862, “IPv6 Stateless Address Autoconfiguration”
  • Kurose, J. F. and Ross, K. W., Computer Networking: A Top-Down Approach, 8th ed., Pearson, 2021, Section 4.3 (“The Internet Protocol (IP)”)
  • Tanenbaum, A. S. and Wetherall, D. J., Computer Networks, 6th ed., Pearson, 2021, Section 5.6 (“The Network Layer”)

For a comprehensive overview, read our article on Cabling Standards.

For a comprehensive overview, read our article on Cdn Guide.

Related Concepts and Further Reading

Understanding ip addressing requires familiarity with several interconnected ideas and principles that together form a complete picture. Exploring these related concepts deepens your knowledge and provides context that makes the core material more meaningful and applicable. Each concept builds on the others, creating a web of understanding that supports deeper learning and practical application. Taking time to explore how these elements connect reveals patterns that accelerate comprehension and retention of new information.

The relationship between ip addressing and adjacent fields is worth particular attention. Many of the most important insights emerge at the boundaries between disciplines, where ideas from different areas combine to create new approaches and solutions that neither field could produce alone. Exploring these connections pays dividends in both breadth and depth of understanding, revealing patterns and principles that might otherwise remain hidden from view. Cross-disciplinary knowledge is increasingly valued as problems become more complex and interconnected.

For those looking to go beyond introductory material, several excellent resources provide deeper treatment of specific aspects of ip addressing. Academic journals, industry publications, authoritative reference works, and online courses each offer different perspectives and levels of detail. The key is to match your reading to your current learning goals and build knowledge progressively, focusing on quality over quantity in your study materials. A well-chosen resource that matches your current level is worth more than dozens of resources that are too basic or too advanced.

Section: Computer Networking 1694 words 8 min read Beginner 756 articles in section Report inaccuracy Back to top