Every time you visit a website, send an email, or make an API call, your device uses an IP address to identify itself.
This address ensures that the data you request finds its way back to you, and the data you send reaches its intended destination.
The Internet Protocol (IP) is the set of rules that governs this addressing system. It operates at Layer 3 (the Network Layer) of the OSI Model, where its primary job is to provide logical addressing and route packets of data from a source device to a destination device across one or more networks.
An IP address is a unique numerical label assigned to each device connected to a network that uses the Internet Protocol for communication. Think of it as a phone number for your computer or a mailing address for your laptop.
It serves two primary functions:
Your IP address is like your home address. The street name and city identify your neighborhood (the network), while your house number identifies your specific home (the device).
Mail carriers (routers) use this address to deliver packages (data packets) to the correct location.
An IP address isn't just a random number; it has a clear structure that is split into two main parts:
For example, in the common IPv4 address 192.168.1.10
with a standard subnet mask, the breakdown is:
192.168.1
10
Routers primarily look at the Network ID. They don't need to know about every single device in the world, only which network a packet is destined for. They use this information to forward the packet to the next router closer to the destination network.
Internet Protocol version 4 (IPv4) is the original and most widely used IP addressing system.
It's a 32-bit address, meaning there are 232 (approximately 4.3 billion) possible unique addresses.
It is written as four numbers separated by dots (dotted-decimal notation), where each number is an "octet" ranging from 0 to 255 (e.g., 172.217.167.78
).
Historically, IPv4 addresses were divided into classes (A, B, C) to define the split between network and host IDs. While this system is now largely replaced by CIDR (see below), it's useful historical context.
10.0.0.0
).172.16.0.0
).192.168.1.0
).The biggest issue with IPv4 is address exhaustion. With the explosion of internet-connected devices, the ~4.3 billion addresses have effectively run out.
To solve the address exhaustion problem, Internet Protocol version 6 (IPv6) was developed.
It's a 128-bit address, providing a staggering 2128 (or 340 undecillion) unique addresses. This is enough to assign an IP address to every atom on the surface of the Earth, and still have addresses left over.
It is written as eight groups of four hexadecimal digits, separated by colons (e.g., 2001:0db8:85a3:0000:0000:8a2e:0370:7334
). Zeros can be compressed for brevity.
IPv6 isn't just bigger; it's better. It includes several built-in improvements:
Not all IP addresses are created equal. They are divided into two main categories:
The standard private IP ranges are:
So how do devices with private IPs access the internet?
Through Network Address Translation (NAT).
Your home router acts as a NAT gateway. It takes requests from devices on your private network, replaces their private source IP with its single public IP, and sends the request to the internet. When the response comes back, the router knows which private device to forward it to.
IP addresses can be assigned in two ways:
As networks grow, it's often necessary to divide them into smaller, more manageable segments. This process is called subnetting. It helps improve performance, enhance security, and organize the network logically.
Subnetting involves "borrowing" bits from the Host ID part of an IP address to create more Network IDs. A subnet mask is used to tell devices which part of the address is the network and which is the host.
This is where CIDR (Classless Inter-Domain Routing) comes in. CIDR abandoned the old classful system and introduced a more flexible way to define the network portion of an address. CIDR notation uses a slash followed by a number to represent the number of bits in the Network ID.
192.168.1.0/24
means the first 24 bits are the Network ID.255.255.255.0
192.168.1.0/26
means the first 26 bits are the Network ID.255.255.255.192
/24
network into four smaller subnets, each with 62 hosts.Besides public and private addresses, there are several special-purpose IP addresses:
127.0.0.1
(IPv4) and ::1
(IPv6). This address, also known as "localhost," always refers to the local device itself. It's used for testing network applications without sending packets out onto the network.192.168.1.255
for the 192.168.1.0/24
network).169.254.0.0/16
range. If a device is configured for DHCP but cannot find a DHCP server, it will assign itself an address from this range to communicate on the local network.