IP addresses explained
The addressing scheme that lets any machine on Earth find any other.
An IP address is the number that identifies a device on a network. IPv4 packs it into 32 bits (four dotted numbers), IPv6 into 128 bits to escape exhaustion. Private ranges hide behind one public address via NAT, CIDR notation carves networks into subnets, and DHCP hands out most addresses automatically while loopback always points home.
IPv4 vs IPv6
IPv4 encodes an address in 32 bits, shown as four dotted decimals like 192.168.1.10, giving about 4.3 billion addresses. That space ran out, so IPv6 uses 128 bits written as eight hex groups, an effectively inexhaustible pool. Both identify a device, but IPv6 also simplifies routing and removes the need for some workarounds.
Public vs private
Public addresses are globally unique and routable across the internet, handed out by regional registries and ISPs. Private ranges — 10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16 — are reserved for internal use and are never routed publicly. That is why your laptop and your neighbour's can both be 192.168.1.10 without conflict.
Subnets & CIDR
An address splits into a network part and a host part, and CIDR notation like 192.168.1.0/24 says the first 24 bits are the network, leaving 8 bits (256 addresses) for hosts. Subnetting slices a large block into smaller networks so traffic stays local and boundaries can be secured. The prefix length is the single number that defines a subnet's size.
NAT
Because private addresses cannot leave the LAN, the router performs Network Address Translation: it rewrites the source of outgoing packets to its single public IP and remembers the mapping. Replies arrive at the public address and are translated back to the right private device using port numbers. This is why an entire household shares one public IP.
Static vs dynamic (DHCP)
A static address is configured by hand and never changes, which suits servers, printers and gateways that others must find reliably. Most devices instead get a dynamic address leased by a DHCP server, which automatically assigns an IP, subnet mask, gateway and DNS for a set time. DHCP is what lets a phone join any Wi-Fi and just work.
Loopback
The address 127.0.0.1 (and ::1 in IPv6) is loopback: it always refers to the local machine itself and never touches the physical network. Packets sent there are handled internally by the OS network stack, which is how a server and a client on the same box talk. It is the go-to address for testing a service locally.
Why addressing exists
A network is useless unless one machine can reliably find another, and the IP address is the number that makes that possible. Every device that speaks the Internet Protocol — laptops, phones, servers, routers, thermostats — gets an address so that packets carrying data know where to be delivered. Without it, the internet would be a pile of wires with no way to say "send this here."
The key idea is that an IP address is a *location on a network*, not a permanent name for a device. It can change when you move networks, and several devices can share one to the outside world. Names like google.com exist precisely because these numbers are hard for humans to remember; DNS translates the friendly name into the IP the machinery actually routes on. Understanding addressing is the foundation for almost everything else in networking, from subnets to firewalls to load balancing.
IPv4 and IPv6
The original scheme, IPv4, stores an address in 32 bits. To make it readable it is written as four decimal numbers separated by dots — 192.168.1.10 — where each number is one byte and therefore ranges from 0 to 255. Thirty-two bits yields roughly 4.3 billion unique addresses, which in the 1980s seemed limitless and today is nowhere near enough for a planet of connected devices.
That exhaustion is why IPv6 exists. It uses 128 bits, written as eight groups of four hexadecimal digits like 2001:0db8:85a3::8a2e:0370:7334, with runs of zeros collapsed to :: for brevity. The address space is so vast it is effectively inexhaustible. Beyond size, IPv6 was designed to simplify routing and header processing and to remove the need for some IPv4-era workarounds. The two protocols do not interoperate directly, so most of the internet runs dual-stack, speaking both while the slow migration to IPv6 continues.
Public, private, and NAT
Not every address is meant to be seen by the whole internet. A public address is globally unique and routable — packets addressed to it can be delivered from anywhere. These are allocated by regional internet registries and handed down through ISPs, and they are a scarce resource.
To conserve them, three private ranges are reserved (defined in RFC 1918) for use inside local networks:
10.0.0.0/8— a huge block, common in large organizations.172.16.0.0/12— a mid-sized block.192.168.0.0/16— the familiar home-router range.
Private addresses are never routed on the public internet, so millions of homes can reuse 192.168.1.10 without conflict. The bridge between the two worlds is NAT (Network Address Translation): your router replaces the private source address on outgoing packets with its one public address, records the mapping (keyed by port), and reverses the translation on the replies. NAT is the reason a whole household of devices shares a single public IP — and, as a side effect, it hides internal machines from direct inbound connections.
Subnets and CIDR notation
Every IP address is conceptually split into two parts: a network portion that identifies which network the device is on, and a host portion that identifies the specific device within it. CIDR (Classless Inter-Domain Routing) notation makes that split explicit with a suffix: in 192.168.1.0/24, the /24 means the first 24 bits are the network part, leaving the remaining 8 bits for hosts — 256 addresses, of which 254 are usable.
Changing the prefix length changes the subnet size: a /16 gives about 65,000 hosts, a /28 gives just 16. Subnetting is the practice of carving a large block into these smaller networks, and it matters for real reasons: it keeps local traffic local (devices in the same subnet talk directly, without a router), it creates security boundaries you can firewall between, and it maps neatly onto departments, floors or services. The subnet mask — 255.255.255.0 is the same thing as /24 — is the older way of writing the identical information. Reading CIDR fluently is a core networking skill because it appears everywhere from cloud VPC design to firewall rules.
Getting an address, and finding home
An address has to be assigned somehow, and there are two ways. A static address is set manually and never changes on its own, which is what you want for machines others must reliably locate: servers, printers, and the router's own gateway address. The trade-off is administrative effort and the risk of duplicate-address mistakes.
Most devices instead use DHCP (Dynamic Host Configuration Protocol). When a device joins a network it broadcasts a request, and a DHCP server (usually the router) leases it a full configuration — an IP address, the subnet mask, the default gateway, and DNS servers — for a limited time. This is why you can walk into a café, join the Wi-Fi, and simply work: DHCP handled all the addressing invisibly. Finally, one address is always special. Loopback — 127.0.0.1 in IPv4, ::1 in IPv6 — always refers to the machine itself; traffic to it never leaves the OS network stack. It is the everyday tool for testing: point a client at localhost and it talks to a server running on the very same computer.
IPv4 is 32 bits written as four dotted decimals (0-255 each); IPv6 is 128 bits in hex to fix address exhaustion.
Private ranges (10.x, 172.16-31.x, 192.168.x) are not routable on the public internet — they live inside local networks.
CIDR notation like /24 marks how many leading bits are the network part, defining the subnet size.
NAT lets many private devices share one public IP by rewriting addresses and ports at the router.
Addresses are either static (manually fixed) or dynamic (leased by DHCP); 127.0.0.1 is loopback, the machine itself.
Quick quiz
Why was IPv6 introduced?
How can two homes both use 192.168.1.10 without conflict?
How DNS works
Turning a human name into a machine address by walking a global hierarchy.
Hub, switch and router explained
Three boxes that look alike but work at completely different layers.
TCP vs UDP
Reliable and ordered, or fast and best-effort — the transport trade-off.
Common ports worth knowing
The port numbers that tell you which service is listening — memorize these and half of networking clicks.