What Is IPv4? Address Structure, Subnet Mask, CIDR and IPv6 Differences

Sunucun 7 min read

What is IPv4? IPv4 (Internet Protocol version 4) is the 32-bit addressing system used to identify devices connected to the internet and local networks. An IPv4 address consists of four numbers separated by dots, each between 0 and 255 (e.g. 192.0.2.10). 32 bits means 232, or about 4.3 billion, different addresses.

Illustration: IPv6

IPv4 was defined in 1981 in RFC 791 and still carries a large share of internet traffic today. This guide explains the structure of an IPv4 address, subnet masks and CIDR notation, private and public IP ranges, NAT, why IPv4 addresses ran out and how IPv4 differs from IPv6.

How to read an IPv4 address

An IPv4 address is really 32 ones and zeros. To make it readable, the 32 bits are split into four groups of 8 bits (octets), and each octet is written as a decimal number:

1st octet2nd octet3rd octet4th octet
Decimal192168110
Binary11000000101010000000000100001010

Because 8 bits can hold at most 255, no octet can be larger than 255; 192.168.1.300 is not a valid IPv4 address.

Network part, subnet mask and CIDR

Every IPv4 address has two parts: the network part, which shows which network the device is on, and the host part, which identifies the device within that network. The subnet mask defines where the boundary is. For example, the mask 255.255.255.0 says that the first 24 bits identify the network and the last 8 bits identify devices.

The same information is written more compactly in CIDR (Classless Inter-Domain Routing) notation: the “/24” in 192.0.2.0/24 means the network part is 24 bits long. Common block sizes:

CIDRSubnet maskTotal addressesTypical use
/32255.255.255.2551A single IP (e.g. a firewall rule)
/30255.255.255.2524Link between two routers
/29255.255.255.2488Small group of servers
/28255.255.255.24016A few servers and services
/27255.255.255.22432Small business network
/26255.255.255.19264Virtual server infrastructure
/25255.255.255.128128Hosting infrastructure
/24255.255.255.0256Smallest block that can be announced on the internet via BGP
/22255.255.252.01,024Mid-sized network
/16255.255.0.065,536Large enterprise network

The first address in a block is the network address and the last is the broadcast address; neither is assigned to devices, and the gateway usually takes one more. So the number of usable IPs is lower than the total: in a /29 block, for example, 5 of the 8 addresses can be assigned to servers.

IPv4 address classes (A, B, C, D, E)

In the early internet, addresses were divided into fixed-size classes. Since the move to CIDR in 1993 classes are no longer used for routing, but you still see them in networking courses and older documents:

ClassFirst octetDefault maskUse
A1–126/8Very large networks
B128–191/16Medium-sized networks
C192–223/24Small networks
D224–239–Multicast
E240–255–Experimental, reserved

Addresses starting with 127 are not part of any class; 127.0.0.0/8 is reserved for loopback, which refers to the device itself (e.g. 127.0.0.1, “localhost”).

Private and public IPv4 addresses

A public IP address is unique on the internet and directly reachable; servers, websites and mail servers use public IPs. Private IP addresses are used only inside local networks, are not routed on the internet and can be reused in different networks. The private ranges reserved by RFC 1918 and other special-purpose blocks:

RangePurpose
10.0.0.0/8Private network (large enterprise networks, cloud internal networks)
172.16.0.0/12Private network (172.16.0.0 – 172.31.255.255)
192.168.0.0/16Private network (home and office routers)
100.64.0.0/10Shared address space for carrier-grade NAT (CGNAT)
127.0.0.0/8Loopback
169.254.0.0/16Link-local; assigned automatically when no DHCP address is received
192.0.2.0/24, 198.51.100.0/24, 203.0.113.0/24Reserved for documentation and examples
224.0.0.0/4Multicast

If your computer gets an address starting with 169.254.x.x, it cannot get an address from the network’s DHCP server (usually the router); check the cable and router connection.

What is NAT and why is it used?

Even with dozens of devices at home, you usually get a single public IP from your internet provider. Your router uses NAT (Network Address Translation) to send the traffic of privately addressed devices to the internet through that single public IP. NAT eased the IPv4 shortage for years, but it makes direct inbound connections to a device difficult. That is why servers, game servers and services such as VPNs that must be reachable from outside need their own public IP address. Some operators put customers behind an extra layer of NAT (CGNAT); in that case the WAN address shown on your router may start with 100.64.x.x.

Static vs dynamic IP address

A dynamic IP may change each time the connection is renewed and is common on home internet. A static IP stays the same; it is needed for servers, camera recording systems, remote desktop and IP-restricted applications. When you rent a server (VDS, cloud or dedicated), you are assigned a static IPv4 address.

Why did IPv4 addresses run out?

4.3 billion addresses seemed plenty in the early days of the internet, but smartphones, servers and IoT devices used them up quickly. Once reserved blocks (private networks, multicast and so on) are subtracted, the usable space is even smaller. IANA, which managed the central pool, handed its last blocks to the regional registries in 2011; RIPE NCC, responsible for Europe, the Middle East and Central Asia, made its last /22 allocation in November 2019. Today new IPv4 demand is met by transferring or leasing existing blocks. The long-term solution is IPv6.

Differences between IPv4 and IPv6

IPv4IPv6
Address length32 bits128 bits
Number of addressesAbout 4.3 billionAbout 3.4 × 1038
NotationDotted decimal (192.0.2.10)Hexadecimal with colons (2001:db8::10)
Header20–60 bytes, variableFixed 40 bytes, with extension headers
Address assignmentManual or DHCPManual, SLAAC or DHCPv6
BroadcastYesNo (multicast and anycast are used)
Need for NATCommonUsually unnecessary thanks to abundant addresses

Although IPv6 is spreading, many internet services are still reachable only over IPv4. That is why servers usually run both protocols together (dual-stack). For migration planning, see our IPv4 to IPv6 migration article.

How to find your IPv4 address

  • Windows: Type ipconfig in Command Prompt; the “IPv4 Address” line shows your local (private) address.
  • Linux: Use ip -4 addr or hostname -I.
  • macOS: Run ipconfig getifaddr en0 (for Wi-Fi).
  • Public IP address: To see the address your router uses on the internet, open a “what is my IP” site or run curl -4 ifconfig.me in a terminal.

When do you need additional IPv4 addresses?

  • Using a separate IP with a clean reputation and a reverse DNS (RDNS) record for a mail server,
  • Running a VPN, a proxy or several services from different IPs,
  • Assigning separate IPs to virtual server or hosting customers,
  • Announcing your own network on the internet via BGP with your own ASN (at least a /24 block).

With Sunucun’s IPv4 lease service you can lease blocks from /29 (5 usable IPs) to /22 (1,022 usable IPs). Reverse DNS records can be set on every block; on /24 and /22 blocks the WHOIS record can be registered in your name. The autonomous system number you need to announce your own network is explained in our what is ASN guide.

Frequently asked questions

How many digits does an IPv4 address have?

An IPv4 address is 32 bits and consists of four numbers separated by dots. Each number is between 0 and 255, so the longest address is 15 characters (e.g. 255.255.255.255).

What does an IP address starting with 192.168 mean?

The 192.168.0.0/16 range is reserved for private networks. These addresses are used in home and office networks and are not routed on the internet; you reach the internet through your router’s public IP.

Have IPv4 addresses run out?

The free pool that registries could allocate is largely exhausted. New demand is met by transferring or leasing existing blocks, while IPv6 is spreading as the long-term solution.

Is IPv4 or IPv6 faster?

The protocol itself does not change speed noticeably; the network path and operators’ routing make the real difference. On some networks IPv6 can show lower latency because there are fewer NAT layers.

Can a server have more than one IPv4 address?

Yes. Several IPs can be configured on a server’s network interface; this is how separate IPs are given to each site, service or virtual machine.

If your servers need additional IP addresses, see the block sizes and current prices on the IPv4 lease page.

Categories

Latest guides