Understanding IP Addresses and Subnets: A Complete Guide
Every device connected to the internet has an IP address — it's the fundamental addressing system that makes network communication possible. Whether you're a developer configuring servers, a network administrator planning infrastructure, or simply curious about how the internet works, understanding IP addresses and subnets is essential knowledge.
This guide will take you from the basics of IP addressing through subnet masks, CIDR notation, and practical subnetting — everything you need to confidently work with network addresses.
What Is an IP Address?
An IP (Internet Protocol) address is a unique numerical label assigned to every device on a network. It serves two purposes: identifying the host (or network interface) and providing the location of the device in the network topology so data can be routed to it.
There are two versions of IP addresses in use today:
IPv4 Addresses
IPv4 is the original and still most widely used format. It consists of four numbers (called octets) separated by dots, where each number ranges from 0 to 255:
192.168.1.100 10.0.0.1 172.16.254.3
Each octet is 8 bits, making an IPv4 address 32 bits total. This gives us approximately 4.3 billion possible addresses — which seemed like plenty in the 1980s but is now exhausted due to the explosive growth of internet-connected devices.
IPv6 Addresses
IPv6 was created to solve the address exhaustion problem. It uses 128 bits, written as eight groups of four hexadecimal digits separated by colons:
2001:0db8:85a3:0000:0000:8a2e:0370:7334
This provides roughly 340 undecillion addresses — enough for every grain of sand on Earth to have trillions of addresses. IPv6 adoption is growing steadily, but IPv4 remains dominant for now, sustained by technologies like NAT (Network Address Translation).
IP Address Classes (IPv4)
IPv4 addresses were originally divided into classes based on the first octet. While classful networking has been replaced by CIDR, understanding the classes helps you recognize address ranges:
- Class A (1–126) — large networks, 16 million hosts per network. Example:
10.0.0.0 - Class B (128–191) — medium networks, 65,534 hosts. Example:
172.16.0.0 - Class C (192–223) — small networks, 254 hosts. Example:
192.168.1.0 - Class D (224–239) — reserved for multicast
- Class E (240–255) — reserved for experimental use
Private IP Address Ranges
Certain IP ranges are reserved for private networks and cannot be routed on the public internet. You'll see these in home and office networks:
10.0.0.0 – 10.255.255.255 (Class A private) 172.16.0.0 – 172.31.255.255 (Class B private) 192.168.0.0 – 192.168.255.255 (Class C private)
Your home router typically assigns addresses from the 192.168.x.x range to your devices, then uses NAT to share a single public IP address with the internet.
What Is a Subnet?
A subnet (short for subnetwork) is a logical division of an IP network. Subnetting allows you to split a large network into smaller, more manageable pieces. Think of it like dividing a large office building into floors — each floor has its own set of room numbers, but they're all part of the same building.
Subnets provide several benefits:
- Security — isolate sensitive systems (e.g., keeping databases on a separate subnet from web servers)
- Performance — reduce broadcast traffic by limiting broadcast domains
- Organization — logically group devices by department, function, or location
- Efficient address use — allocate only as many addresses as needed for each network segment
Subnet Masks Explained
A subnet mask determines which portion of an IP address identifies the network and which portion identifies the host. It's a 32-bit number that "masks" the network part of the address.
For example, the subnet mask 255.255.255.0 means the first three octets identify the network, and the last octet identifies hosts within that network:
IP Address: 192.168.1.100 Subnet Mask: 255.255.255.0 Network: 192.168.1.0 Host part: .100 Usable range: 192.168.1.1 – 192.168.1.254 Broadcast: 192.168.1.255
The first address in a subnet is the network address (not assignable to hosts), and the last address is the broadcast address (used to send data to all hosts in the subnet). That's why a /24 network has 254 usable addresses, not 256.
CIDR Notation
CIDR (Classless Inter-Domain Routing) notation is the modern, compact way to express subnet masks. Instead of writing out the full mask, you append a slash followed by the number of network bits:
192.168.1.0/24 = 255.255.255.0 (256 addresses, 254 usable) 10.0.0.0/8 = 255.0.0.0 (16,777,216 addresses) 172.16.0.0/16 = 255.255.0.0 (65,536 addresses) 192.168.1.0/28 = 255.255.255.240 (16 addresses, 14 usable)
The number after the slash tells you how many bits are used for the network portion. A higher number means a smaller network with fewer hosts.
Common CIDR Blocks
/32— single host (1 address)/28— 16 addresses, 14 usable hosts/24— 256 addresses, 254 usable hosts (most common for small networks)/16— 65,536 addresses/8— 16.7 million addresses
How to Calculate Subnets
Subnetting by hand involves binary math, but the core concept is straightforward. Here's how to calculate a subnet:
Step 1: Determine Your Needs
How many hosts do you need? The formula for usable hosts is 2^(32 - prefix length) - 2. The minus 2 accounts for the network and broadcast addresses.
Step 2: Choose the Right Prefix Length
If you need 50 hosts, you need at least 6 host bits (2^6 = 64, minus 2 = 62 usable). That gives you a /26 network.
Step 3: Calculate the Network Details
Network: 192.168.1.0/26 Subnet Mask: 255.255.255.192 Usable Range: 192.168.1.1 – 192.168.1.62 Broadcast: 192.168.1.63 Next subnet: 192.168.1.64/26
Of course, doing this manually for complex network designs is tedious and error-prone. That's why subnet calculators exist.
Practical Subnetting Examples
Home Network
A typical home router uses 192.168.1.0/24, giving you 254 usable addresses. More than enough for phones, laptops, smart devices, and IoT gadgets. No subnetting needed.
Small Office
An office with 100 employees might use 10.0.1.0/24 for workstations and 10.0.2.0/24 for servers. This separates traffic and adds a layer of security between the two groups.
Cloud Infrastructure
In AWS or GCP, you typically create a VPC with a large block like 10.0.0.0/16, then carve it into smaller subnets: /24 for public-facing resources, /24 for private databases, and /28 for load balancers that need only a few IPs.
Special IP Addresses to Know
127.0.0.1— localhost (loopback), always refers to the current machine0.0.0.0— represents "all interfaces" when binding a server, or "unknown" as a source255.255.255.255— limited broadcast, reaches all devices on the local network169.254.x.x— link-local addresses, auto-assigned when DHCP fails8.8.8.8/1.1.1.1— Google and Cloudflare public DNS servers
Finding Your IP Address
To find your device's IP address, use these commands:
# Windows ipconfig # macOS / Linux ifconfig # or ip addr show
This shows your private (local) IP. To find your public IP — the one the rest of the internet sees — you can use our IP Lookup tool or run curl ifconfig.me from the command line.
Conclusion
IP addresses and subnets form the backbone of all network communication. Understanding how they work gives you the foundation to configure servers, plan network architectures, troubleshoot connectivity issues, and secure your infrastructure.
The key takeaways: IPv4 addresses are 32-bit numbers divided into network and host portions by a subnet mask. CIDR notation provides a clean way to express subnets. And when you need to quickly calculate subnet details, use a tool instead of doing binary math by hand.