What is IPv4?
IPv4 (Internet Protocol version 4) is the fourth version of the internet protocol, which provides addressing and routing of packets in TCP/IP networks.
Short phrasing for the interview:
IPv4 is a network-layer protocol that assigns unique 32-bit IP addresses to devices and delivers packets from a sender to a receiver.
IPv4 is the foundation of the internet and local networks.
Structure of an IPv4 address
An IPv4 address is 32 bits, divided into 4 octets.
Example:
192.168.10.25
In binary form:
11000000.10101000.00001010.00011001
Range of each octet: 0-255.
Tasks of IPv4
- Addressing devices Each device gets a unique IP within a network.
- Routing Packets travel through routers from network to network.
- Fragmentation and reassembly of packets If the MTU is smaller than the packet size, IPv4 can split it into parts.
- Data encapsulation Data from TCP/UDP is packed into an IPv4 header.
Structure of an IPv4 packet (header)
Main header fields:
- Version - protocol version (4)
- Source IP - the sender's IP
- Destination IP - the receiver's IP
- TTL - limits the number of hops
- Protocol - which protocol is inside (TCP/UDP/ICMP)
- Total Length - the packet's length
Full header: 20-60 bytes.
Types of IPv4 addresses
1. Public (external)
Used on the internet. Unique worldwide.
2. Private (internal)
Used in local networks (not routed on the internet).
Ranges:
- 10.0.0.0/8
- 172.16.0.0/12
- 192.168.0.0/16
3. Loopback
127.0.0.0/8 Usually: 127.0.0.1 - localhost.
4. APIPA (Link-local)
169.254.0.0/16 Assigned automatically when DHCP is unavailable.
5. Multicast
224.0.0.0 - 239.255.255.255
6. Broadcast
Broadcast address: x.x.x.255 (in the classic mask)
IPv4 and subnet masks
A subnet mask is used to split a network into subnets, for example:
255.255.255.0 → /24
It divides the address into:
- the network part
- the host part
Example of a /24 network:
192.168.1.0/24
Hosts: 192.168.1.1 - 192.168.1.254
Broadcast: 192.168.1.255The problem with IPv4
1. Limited number of addresses: 2^32 = 4,294,967,296
That turned out to be too few for the whole world, so the industry started widely using:
- NAT
- private networks
- CIDR
- dynamic address allocation
2. IPv4 is officially exhausted
Regional internet registries (RIPE, ARIN, and others) have handed out their last pools.
That is why IPv6 is being developed.
IPv4 vs IPv6 (briefly)
| IPv4 | IPv6 |
|---|---|
| 32 bits | 128 bits |
| 4.3 billion addresses | ~3.4×10^38 |
| Notation: 192.168.1.1 | Notation: 2001:db8::1 |
| Widely used | Gradually being adopted |
| NAT is mandatory | Enough addresses, NAT is not needed |
Examples of IPv4 use in reality
- a home router hands out addresses like 192.168.x.x
- a web server has a public IP like 203.x.x.x
- a computer reaches 8.8.8.8 (Google DNS)
- a router splits a network into subnets /24, /30, /16
Ready answer for the interview
IPv4 is a network-layer protocol that provides addressing and delivers packets in TCP/IP networks. It uses 32-bit IP addresses, written as four numbers separated by dots. IPv4 defines routing, fragmentation, and the packet format. The main problem with IPv4 is its limited number of addresses, which is why IPv6 is gradually being adopted.
Cheat sheet (5 seconds before the interview)
- IPv4 = a 32-bit IP protocol.
- Address: 4 octets (0-255).
- Format: A.B.C.D, example: 192.168.1.10.
- Private ranges: 10/8, 172.16/12, 192.168/16.
- Packets are routed by IP.
- Problem: too few addresses, so IPv6 was needed.
Short Answer
Interview readyA concise answer to help you respond confidently on this topic during an interview.