🌐

IPv4

IPv4 (Internet Protocol version 4) is the predominant IP address format on the Internet, with 32 bits represented in dotted decimal notation (example: 192.168.1.1). It allows ~4.3 billion unique addresses, a space practically exhausted since 2011.

IPv4 was defined in 1981 in RFC 791, part of the TCP/IP model that underpins the Internet. It's the fourth version of the protocol (v1-v3 were experimental) and became the de facto standard for identifying devices on networks.

An IPv4 address is 32 bits divided into 4 octets (8 bits each), written in decimal separated by dots. Example: 192.168.0.1 looks like this in binary: 11000000.10101000.00000000.00000001.

The total space: 2³² = 4,294,967,296 addresses. Sounds like a lot, but they were officially exhausted in February 2011 when IANA assigned the last blocks. Today we survive thanks to NAT (Network Address Translation) that allows thousands of devices to share one public IP.

Each device on the Internet needs a unique IP to communicate. It's like your postal address: without it, data packets don't know where to go. IPv4 operates at layer 3 of the OSI model (network layer) and is independent of physical medium (WiFi, Ethernet, fiber).

IPv4 was originally divided into classes based on the first bits:

  • Class A: first bit 0. Range 0.0.0.0 to 127.255.255.255. 8 bits network, 24 bits hosts (16M hosts per network). For huge networks (global companies).
  • Class B: first bits 10. Range 128.0.0.0 to 191.255.255.255. 16 bits network, 16 bits hosts (65K hosts). Medium organizations.
  • Class C: first bits 110. Range 192.0.0.0 to 223.255.255.255. 24 bits network, 8 bits hosts (254 hosts). Small networks.
  • Class D: first bits 1110. Range 224.0.0.0 to 239.255.255.255. Multicast (one packet to multiple receivers).
  • Class E: first bits 1111. Range 240.0.0.0 to 255.255.255.255. Reserved, experimentation.

This classful system was replaced in 1993 by CIDR (Classless Inter-Domain Routing). Today arbitrary subnet masks are used: 192.168.1.0/24 means the first 24 bits are network, the last 8 are hosts (256 addresses, 254 usable).

Private addresses (RFC 1918), not routable on public Internet:

  • 10.0.0.0/8 (10.0.0.0 to 10.255.255.255) — 16M addresses
  • 172.16.0.0/12 (172.16.0.0 to 172.31.255.255) — 1M addresses
  • 192.168.0.0/16 (192.168.0.0 to 192.168.255.255) — 65K addresses

Your home network uses one of these. The router does NAT to translate private to your public IP.

NAT (Network Address Translation) was the temporary solution to exhaustion. Your home has one public IP (e.g., 200.45.123.89) but internally your devices use private IPs (192.168.1.x). The router translates: when your PC (192.168.1.10) requests a website, the router rewrites the packet with its public IP + a unique port, tracks the connection, and forwards the response back.

NAT allowed the Internet to keep growing after 2011, but has costs: complexity (configuring port forwarding is painful), hinders P2P (two devices behind NAT can't connect directly without relay), and breaks end-to-end connectivity (one of the original Internet principles).

Today secondary markets exist where companies sell IPv4 blocks. An IPv4 /24 (256 addresses) trades at ~$6,000 USD. More expensive than many premium domains.

IPv6 is the definitive solution: 128 bits = 340 undecillion addresses (3.4 × 10³⁸). Enough to assign thousands of IPs to each atom on the planet. Deployment is slow (~40% of web traffic uses IPv6 in 2024) due to inertia and investments in IPv4 infrastructure.

Network diagnostics: ping 8.8.8.8 verifies connectivity to Google's DNS. traceroute 1.1.1.1 shows the path your packets take to Cloudflare.

Server configuration: when deploying a backend, you configure firewalls to allow traffic only from specific IPs. AWS Security Groups, iptables on Linux, all work with IPv4 ranges.

Geolocation: databases like MaxMind associate IPv4 ranges with geographic locations. That's how Netflix knows which country you're connecting from.

Random IP generation: useful for testing distributed systems, traffic simulation, or populating test databases. Genfy offers a generator that respects valid ranges and avoids reserved ranges.

Subnetting: dividing a large network into smaller subnets. Example: a company receives 203.0.113.0/24 (256 IPs). It divides it into 4 /26 subnets (64 IPs each) for different departments. Subnet calculators automate this.

Examples

  • 192.168.1.1 — Typical home router private IP
  • 8.8.8.8 — Google's public DNS
  • 10.0.0.0/8 — Complete Class A private range
  • 203.0.113.0/24 — Documentation range (RFC 5737)
  • 127.0.0.1 — Localhost, always points to your own machine

FAQ

Why is my IP 192.168.x.x and not my public IP?

192.168.x.x is your private IP within your local network. Your router does NAT: translates that private IP to your public IP (what Internet sees). Check your public IP at sites like ifconfig.me.

What happens if two devices have the same IP?

On the same local network: IP conflict, both lose connectivity or behave erratically. On different networks: no problem, private IPs are reused in millions of networks (that's why they exist).

When should I use IPv6 instead of IPv4?

If you're deploying new infrastructure, enable IPv6 from the start. Modern clouds (AWS, GCP) support it natively. For existing services, dual-stack (IPv4 + IPv6) is the safe transition.