IPv4 (Internet Protocol version 4) — the fourth version of the IP protocol, which still carries most of the internet. An IPv4 address is a 32-bit number, usually written as four decimal numbers separated by dots: 192.168.1.1.
Structure of an IPv4 address
192 . 168 . 1 . 1
^ ^ ^ ^
| | | Host (device number)
| | Subnet
| Network
Network class
Each number is one byte (0–255). In total: 4 bytes × 8 bits = 32 bits = ~4.3 billion possible addresses.
Subnet masks and CIDR notation
| CIDR | Mask | Hosts | Example |
|---|---|---|---|
| /8 | 255.0.0.0 | 16 777 214 | 10.0.0.0/8 |
| /16 | 255.255.0.0 | 65 534 | 172.16.0.0/16 |
| /24 | 255.255.255.0 | 254 | 192.168.1.0/24 |
| /28 | 255.255.255.240 | 14 | 192.168.1.16/28 |
| /30 | 255.255.255.252 | 2 | 10.0.0.0/30 (P2P) |
| /32 | 255.255.255.255 | 1 | A single host |
Private (RFC 1918) ranges
These addresses are not routed on the internet — only inside local networks:
| Range | CIDR | Purpose |
|---|---|---|
| 10.0.0.0 – 10.255.255.255 | /8 | Corporate networks |
| 172.16.0.0 – 172.31.255.255 | /12 | Medium-sized organizations |
| 192.168.0.0 – 192.168.255.255 | /16 | Home networks, offices |
| 127.0.0.0 – 127.255.255.255 | /8 | Loopback (127.0.0.1) |
Checking your own IPv4 address
# On Linux — external IP
curl ifconfig.me
# Local IP of the interfaces
ip addr show
# or
ifconfig
Why IPv4 addresses are running out
32 bits = 4 294 967 296 addresses. Of those, ~600 million are reserved (private, multicast, loopback). IANA exhausted its pool of free /8 blocks back in 2011. Regional registries (RIPE, ARIN) have been running down their stock since 2019–2023.
Diagnosing common addressing errors
The server got an IP but is unreachable from outside, even though the interface is "up" — a common cause is that the address was assigned in a subnet that does not match the gateway's network, so packets cannot leave the local segment.
ip addr show eth0
inet 192.168.1.50/24
ip route show
default via 10.0.0.1 dev eth0
# Gateway 10.0.0.1 is not part of network 192.168.1.0/24 - the route does not work
An interface's IP address and its default gateway must sit in the same subnet (given the mask). If the provider assigned 192.168.1.50/24, the gateway must look like 192.168.1.1, not belong to a different network.
Two servers with the same IP conflict on the local network — in the logs this shows up as constant dropped connections and ARP messages about duplication.
dmesg | grep -i duplicate
IPv4: 192.168.1.50 is already in use! (kernel arp)
This happens when static IPs are assigned by hand without accounting for the DHCP pool, or when a VPS is cloned without changing the network settings. Check the DHCP range on the router and make sure static addresses are placed outside it.
Address classes: a historical note
| Class | First octet range | Default mask | Relevance today |
|---|---|---|---|
| A | 1-126 | /8 | Unused, replaced by CIDR |
| B | 128-191 | /16 | Unused, replaced by CIDR |
| C | 192-223 | /24 | Unused, replaced by CIDR |
| D (multicast) | 224-239 | - | Used for multicast groups |
When IPv4 is no longer enough
- A project needs many public addresses at once (for example thousands of virtual hosts with their own IP) — renting that many IPv4 addresses is expensive and often physically limited at the provider.
- You need to support a growing number of IoT devices with direct addressing — IPv4 with NAT complicates such scenarios, and IPv6 removes that limit thanks to its huge address space.
- A partner or regulator requires IPv6 compatibility (some government contracts and mobile networks are already IPv6-first) — then IPv4 is needed alongside it, not instead of it.
- The host limits the number of extra IPv4 addresses per account — if a project needs more public addresses than the provider's limit allows, that is an architectural constraint, not a technical setting.
Verifying the result
- Check the assigned address:
ip addr showmust show the right IP with the correct mask on the right interface. - Check the default route:
ip route show defaultmust point to a gateway inside the same subnet. - Check connectivity:
ping -c 3 8.8.8.8must get replies with no packet loss. - Check DNS resolution from this address:
curl -4 ifconfig.memust return exactly the expected public IP.
Mask and range calculations are covered in detail in the article on CIDR, and the mechanism for hiding private addresses behind one public address is covered in the article on NAT.