IP Addresses and Subnets
Table of Contents
What Is an IP Address?
An IP address (Internet Protocol address) is a unique numerical label assigned to every device connected to a computer network that uses the Internet Protocol for communication. Think of it like a street address for your computer — it tells other devices where to send data. Without IP addresses, devices on the internet would have no way to find each other or exchange information.
IP addresses serve two primary functions: host or network interface identification and location addressing. They allow routers to forward packets to the correct destination across interconnected networks. Every time you visit a website, send an email, or stream a video, your device's IP address is used to route that data back to you.
An IP address is typically displayed in a human-readable format. For IPv4, this looks like 192.168.1.1. For IPv6, it looks like 2001:0db8:85a3:0000:0000:8a2e:0370:7334. Your Internet Service Provider (ISP) assigns you a public IP address, while your router assigns private IP addresses to devices on your local network.
IPv4 vs IPv6
IPv4 (Internet Protocol version 4) was introduced in 1981 and uses 32-bit addresses, allowing for approximately 4.3 billion unique addresses (232). IPv6 was developed in the late 1990s to address IPv4 exhaustion, using 128-bit addresses that provide roughly 340 undecillion (2128) unique addresses.
| Feature | IPv4 | IPv6 |
|---|---|---|
| Address Length | 32 bits | 128 bits |
| Format | Dotted decimal (e.g., 192.168.1.1) | Hexadecimal colon-separated |
| Total Addresses | ~4.3 billion | ~3.4 × 1038 |
| Header Size | 20 bytes (variable) | 40 bytes (fixed) |
| Configuration | Manual or DHCP | SLAAC, DHCPv6, or manual |
| IPSec Support | Optional | Built-in (mandatory) |
| Checksum in Header | Yes | No (handled by link layer) |
| NAT Required | Commonly used | Not needed (enough addresses) |
The transition from IPv4 to IPv6 is ongoing. Most modern operating systems and networks support dual-stack operation, meaning they can handle both IPv4 and IPv6 traffic simultaneously. Tools like dig and nslookup can query both A (IPv4) and AAAA (IPv6) records to verify connectivity.
IPv4 Address Classes
IPv4 addresses were historically divided into five classes (A through E) based on their leading bits. While classful addressing has been replaced by CIDR (Classless Inter-Domain Routing), understanding the original classes helps when reading older documentation and recognizing address ranges.
| Class | Leading Bits | First Octet Range | Default Subnet Mask | Purpose |
|---|---|---|---|---|
| A | 0 | 1 – 126 | 255.0.0.0 (/8) | Large organizations |
| B | 10 | 128 – 191 | 255.255.0.0 (/16) | Medium organizations |
| C | 110 | 192 – 223 | 255.255.255.0 (/24) | Small organizations |
| D | 1110 | 224 – 239 | N/A | Multicasting |
| E | 1111 | 240 – 255 | N/A | Experimental / reserved |
Note that the range 127.0.0.0 – 127.255.255.255 is reserved for loopback testing. When you ping 127.0.0.1, you are testing your own network interface. This range was originally part of Class A but is now universally reserved.
Private and Reserved IP Ranges
Not all IP addresses are routable on the public internet. RFC 1918 defines three ranges reserved for private networks. These addresses can be used freely within a local network but cannot be reached directly from the internet — traffic from private addresses must pass through NAT to communicate externally.
| Range | CIDR | Number of Addresses | Typical Use |
|---|---|---|---|
| 10.0.0.0 – 10.255.255.255 | 10.0.0.0/8 | 16,777,216 | Large enterprise networks |
| 172.16.0.0 – 172.31.255.255 | 172.16.0.0/12 | 1,048,576 | Medium networks, Docker defaults |
| 192.168.0.0 – 192.168.255.255 | 192.168.0.0/16 | 65,536 | Home networks, small offices |
| 169.254.0.0 – 169.254.255.255 | 169.254.0.0/16 | 65,536 | Link-local (APIPA) addresses |
| 127.0.0.0 – 127.255.255.255 | 127.0.0.0/8 | 16,777,216 | Loopback testing |
When troubleshooting connectivity, knowing whether your device has a private address, a public address, or a link-local address (169.254.x.x) can immediately tell you whether the issue is with DHCP, your router, or your ISP.
Subnet Masks and CIDR Notation
A subnet mask divides an IP address into the network portion and the host portion. In binary, a subnet mask consists of consecutive 1-bits (identifying the network) followed by consecutive 0-bits (identifying hosts). CIDR notation expresses this more concisely by counting the number of 1-bits.
For example, the subnet mask 255.255.255.0 in binary is 11111111.11111111.11111111.00000000 — twenty-four 1-bits followed by eight 0-bits. This is written as /24 in CIDR notation and provides 256 addresses (254 usable hosts, since the first is the network address and the last is the broadcast address).
| CIDR | Subnet Mask | Total Addresses | Usable Hosts | Common Use |
|---|---|---|---|---|
| /8 | 255.0.0.0 | 16,777,216 | 16,777,214 | Class A network |
| /16 | 255.255.0.0 | 65,536 | 65,534 | Class B network |
| /24 | 255.255.255.0 | 256 | 254 | Small LAN segment |
| /25 | 255.255.255.128 | 128 | 126 | Split a /24 in half |
| /26 | 255.255.255.192 | 64 | 62 | Small department |
| /28 | 255.255.255.240 | 16 | 14 | Point-to-point links |
| /30 | 255.255.255.252 | 4 | 2 | WAN links |
| /32 | 255.255.255.255 | 1 | 1 | Single host route |
How Subnetting Works
Subnetting is the practice of dividing a large network into smaller, more manageable sub-networks (subnets). This improves performance by reducing broadcast traffic, enhances security by isolating segments, and makes efficient use of available address space.
Example: Suppose you have the network 192.168.1.0/24 (254 usable hosts) and need to create four separate subnets. By borrowing 2 bits from the host portion, you change the mask from /24 to /26, creating four subnets of 62 usable hosts each:
| Subnet | Network Address | First Usable | Last Usable | Broadcast |
|---|---|---|---|---|
| Subnet 1 | 192.168.1.0/26 | 192.168.1.1 | 192.168.1.62 | 192.168.1.63 |
| Subnet 2 | 192.168.1.64/26 | 192.168.1.65 | 192.168.1.126 | 192.168.1.127 |
| Subnet 3 | 192.168.1.128/26 | 192.168.1.129 | 192.168.1.190 | 192.168.1.191 |
| Subnet 4 | 192.168.1.192/26 | 192.168.1.193 | 192.168.1.254 | 192.168.1.255 |
To determine which subnet an IP belongs to, perform a bitwise AND between the IP address and the subnet mask. For instance, 192.168.1.70 AND 255.255.255.192 = 192.168.1.64, so this host is on Subnet 2.
Network Address Translation (NAT)
NAT is a technique used by routers to translate private IP addresses into a single public IP address (or a pool of public addresses) before traffic reaches the internet. This was developed primarily to conserve IPv4 addresses — a single household with 20 devices can share one public IP address thanks to NAT.
There are several types of NAT:
- Static NAT: Maps one private IP to one public IP permanently. Used when a device needs to be reachable from the internet (e.g., a web server).
- Dynamic NAT: Maps private IPs to a pool of public IPs on a first-come, first-served basis.
- Port Address Translation (PAT) / NAT Overload: The most common type for home networks. Multiple private IPs share one public IP, distinguished by unique port numbers. When your device sends a request, the router assigns a port number and tracks the mapping.
NAT is transparent to most applications, but it can cause issues with protocols that embed IP addresses in their data payload (like FTP or SIP). Techniques like STUN, TURN, and ICE were developed to work around NAT traversal problems in real-time communication protocols.
Common IP Range Reference Table
The following table summarizes commonly encountered IP ranges and their purposes, useful for network configuration and troubleshooting:
| Range / Address | Name | Purpose |
|---|---|---|
| 0.0.0.0/8 | Current network | Represents the default route or "this network" |
| 10.0.0.0/8 | Private Class A | Large internal networks (RFC 1918) |
| 100.64.0.0/10 | Carrier-grade NAT | Shared address space between ISP and customer (RFC 6598) |
| 127.0.0.0/8 | Loopback | Localhost testing, traffic never leaves the host |
| 169.254.0.0/16 | Link-local (APIPA) | Auto-assigned when DHCP fails |
| 172.16.0.0/12 | Private Class B | Medium internal networks (RFC 1918) |
| 192.168.0.0/16 | Private Class C | Home and small office networks (RFC 1918) |
| 224.0.0.0/4 | Multicast | One-to-many communication (IGMP, streaming) |
| 255.255.255.255 | Limited broadcast | Broadcast to all hosts on the local network |
Understanding IP addressing and subnetting is foundational for networking. Whether you are configuring a home router, designing a corporate network, or troubleshooting connectivity issues, these concepts apply at every level. Use our IP Lookup tool to check your current public IP address and related information.