IP Addressing, NAT & IPv6 Explained
Every packet traveling across the internet carries two numeric endpoints in its header: where it originated and where routers should deliver it next. Those endpoints are IP addresses — and understanding how they are structured, shared via NAT, and transitioning to IPv6 solves a huge share of everyday networking and server troubleshooting issues.
1. Why Routers Need Numeric Addresses (and Humans Use DNS)
When you type showmyip.xyz into a browser, your device does not send packets directly to that text string. Instead, your operating system asks a Domain Name System (DNS) resolver to translate the human-friendly name into a numeric IP address. Internet backbone routers operate strictly on those numeric prefixes because fixed-length binary addresses can be matched in specialized hardware routing tables in nanoseconds.
This separation gives the web flexibility: an organization can move a website to a new data center or place it behind a global CDN simply by updating its DNS A or AAAA records, without changing the domain name users remember.
2. IPv4 Architecture and Why It Ran Out
Internet Protocol version 4 (IPv4) encodes each address as a 32-bit unsigned integer. To make it easier to read, the 32 bits are split into four 8-bit octets rendered in decimal from 0 to 255, separated by dots — for example, 203.0.113.42.
Because 32 bits can represent exactly 232 = 4,294,967,296 combinations — and hundreds of millions of those are reserved for private networks, multicast, loopback, and legacy allocations — global free pools of IPv4 addresses were exhausted at the IANA level in 2011 and at regional registries over the following decade. Today, unused IPv4 blocks trade on secondary transfer markets, and network engineers rely heavily on two survival mechanisms: Network Address Translation (NAT) and IPv6.
3. IPv6: 128-Bit Addressing & Compression Rules
IPv6 expands the address field from 32 bits to 128 bits, providing roughly 3.4 × 1038 unique addresses. Rather than dotted decimal, IPv6 is written as eight 16-bit hexadecimal groups separated by colons:
Full form: 2001:0db8:0000:0000:0000:0000:0042:0001
Compressed form: 2001:db8::42:1
Two deterministic rules (standardized in RFC 5952) shorten IPv6 strings without ambiguity:
- Drop leading zeros inside each group:
0db8becomesdb8, and0001becomes1. Trailing zeros are never dropped (0040becomes40, not4). - Collapse one longest run of all-zero groups into
::: You may use::at most once per address; otherwise a parser could not know how many zero groups belong in each gap.
Most modern ISPs and mobile networks operate dual-stack, assigning both an IPv4 and an IPv6 address so devices automatically prefer IPv6 when the destination supports it and fall back seamlessly to IPv4 when it does not.
4. Reserved & Non-Routable IPv4 Address Blocks
Not every IPv4 address can travel across the public internet. Core internet routers drop packets destined for special-purpose ranges defined by the IETF:
| CIDR Range | Purpose | RFC | Where You Encounter It |
|---|---|---|---|
| 10.0.0.0/8 | Private Network | RFC 1918 | Corporate LANs, cloud VPCs (AWS/GCP/Azure) |
| 172.16.0.0/12 | Private Network | RFC 1918 | Docker bridge networks, enterprise subnets |
| 192.168.0.0/16 | Private Network | RFC 1918 | Home Wi-Fi routers and small office LANs |
| 100.64.0.0/10 | Carrier-Grade NAT | RFC 6598 | ISP subscriber uplinks sharing one public IPv4 |
| 127.0.0.0/8 | Loopback | RFC 1122 | Localhost development servers (127.0.0.1) |
| 169.254.0.0/16 | Link-Local (APIPA) | RFC 3927 | Auto-assigned when DHCP fails; cloud instance metadata (169.254.169.254) |
| 192.0.2.0/24 198.51.100.0/24 203.0.113.0/24 | Documentation | RFC 5737 | Safe example IPs for tutorials and test configs |
5. How NAT and Carrier-Grade NAT (CGNAT) Work
If your laptop shows 192.168.1.45 in Wi-Fi settings, how do websites see a completely different public IP? Your home router performs Port Address Translation (PAT / NAT). When your laptop opens an outbound HTTPS connection, the router rewrites the packet's source IP to the router's single public WAN IP, assigns a unique temporary source port, and records that mapping in a state table. When the server replies to that port, the router translates the destination back to 192.168.1.45.
Many fiber and cellular ISPs add a second layer called Carrier-Grade NAT (CGNAT). Instead of giving your home router a public IPv4 address, the ISP hands your router an address inside 100.64.0.0/10 and translates hundreds of subscribers behind a shared pool of public IPv4 addresses. CGNAT conserves IPv4 space, but breaks inbound port forwarding and can occasionally trigger CAPTCHAs if another subscriber sharing your exit IP triggers rate limits.
6. Dynamic DHCP Leases vs. Static Assignments
Consumer broadband accounts generally receive dynamic IPs leased via DHCP or PPPoE. Even though leases are dynamic, many modern cable and fiber ISPs keep the same IP attached to your modem's MAC address for months unless you change hardware or power the modem off for an extended period. Businesses hosting mail servers, VPN gateways, or IP-allowlisted APIs pay extra for static IPs so DNS records and firewall allowlists never break unexpectedly.
7. Practical Commands to Inspect Your Local & Public IP
Knowing the difference between your local interface IP and your public exit IP saves time during debugging:
# Linux: inspect local interfaces and CIDR masks
ip -brief addr
# macOS: inspect Wi-Fi interface (usually en0)
ipconfig getifaddr en0
# Windows (Command Prompt / PowerShell)
ipconfig
# Check the public IPv4 or IPv6 seen by external servers
curl -4 https://ifconfig.me
curl -6 https://ifconfig.me
Next in this series: How IP Geolocation Actually Works → | Practical Guide to CIDR & Subnetting →