Skip to main content

What Is IPv4: Addressing, Subnet Masks, and Network Classes

VDS / VPS · 19.04.2026 · 5 min read
Illustration for “What Is IPv4: Addressing, Subnet Masks, and Network Classes”

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

CIDRMaskHostsExample
/8255.0.0.016 777 21410.0.0.0/8
/16255.255.0.065 534172.16.0.0/16
/24255.255.255.0254192.168.1.0/24
/28255.255.255.24014192.168.1.16/28
/30255.255.255.252210.0.0.0/30 (P2P)
/32255.255.255.2551A single host

Private (RFC 1918) ranges

These addresses are not routed on the internet — only inside local networks:

RangeCIDRPurpose
10.0.0.0 – 10.255.255.255/8Corporate networks
172.16.0.0 – 172.31.255.255/12Medium-sized organizations
192.168.0.0 – 192.168.255.255/16Home networks, offices
127.0.0.0 – 127.255.255.255/8Loopback (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.

💡 For VPS: A public IPv4 address is a scarce resource that already costs money (~$1–5/month for an additional IP). That is exactly why providers are moving to IPv6 and using NAT for VPS.
⚠️ NAT and its problems: Many hosts hand out a VPS with an address behind NAT — you have a "public" IP, but it is shared. That limits what you can do: a mail server, a VPN and some APIs do not work behind NAT. Check the IP type with your provider.

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

ClassFirst octet rangeDefault maskRelevance today
A1-126/8Unused, replaced by CIDR
B128-191/16Unused, replaced by CIDR
C192-223/24Unused, 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

  1. Check the assigned address: ip addr show must show the right IP with the correct mask on the right interface.
  2. Check the default route: ip route show default must point to a gateway inside the same subnet.
  3. Check connectivity: ping -c 3 8.8.8.8 must get replies with no packet loss.
  4. Check DNS resolution from this address: curl -4 ifconfig.me must 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.

Was this article helpful?
← Back to Knowledge Base Ask Support