Day - 53 of DevOps

Day - 53 of DevOps

IPv4 and IPv6

Welcome to Day 53 of the #100DaysOfDevOps Challenge! Today we will cover the Difference Between IPv4 and IPv6.

Currently two versions of the Internet Protocol (IP): IPv4 and IPv6. Both types enable online networking and data exchange, but the two versions identify devices differently and offer distinct features. So, which one is better, faster, and more secure?

This article offers a head-to-head comparison of IPv4 and IPv6, the two currently available IPs for routing traffic across the Internet. Read on to learn the main differences between the two protocols and see why switching to IPv6 is vital to the long-term health of the Internet.

What Is IP?

The Internet Protocol (IP) is a set of networking rules that enable computers to communicate over the Internet. IP has two primary purposes:

  • Enable different computers to exchange data over the Internet while ensuring sent files arrive at the correct destination.

  • Identify every device and domain that connects to the Internet by assigning a unique IP address (a series of digits that identify a specific computer or device).

When you send something online, the IP breaks data into smaller chunks called packets. Each packet has attached IP info that ensures whatever you send reaches the right recipient. This process occurs automatically and looks like this:

  • The sender's computer connects to the Internet via a local router, either at home or within an office server room.

  • The router (which has a static IP address that never changes) assigns a temporary (a.k.a. dynamic) IP address to the device to enable communication.

  • IP converts files into datagrams with a header (info consisting of IP source/destination and metadata) and the payload (the data itself).

  • The protocol nests data into packets.

  • IP breaks down data packets (fragmentation) and sends them over the Internet to the specified IP address.

  • Once data reaches its destination, IP rebuilds the file (reassembly) to allow access.

The Internet Protocol does not assign IP addresses at random. A non-profit organization called Internet Corporation for Assigned Names and Numbers (ICANN) allocates IP addresses to Internet Service Providers (ISPs) who assign addresses to end-user devices.

Most networks combine IP with TCP (Transmission Control Protocol) or UDP (User Datagram Protocol) to form a connection between devices. All three are a part of the broader Internet Protocol Suite (TCP/IP) that governs rules for routing and receiving data over a network.

What Is IPv4?

IPv4 is the first major version of the Internet Protocol that's been the go-to communication model for the Internet since the 1980s. This protocol "carried" 94% of all online traffic in 2021.

IPv4 assigns 32-bit IP addresses to devices. Each address has four groups of numbers (8-bit sections called octets) separated by a period, such as:

192.158.1.38

The value of each octet ranges from 0 to 255, so the IPv4 model includes every address between 0.0.0.0 and 255.255.255.255. All IPv4 addresses have two parts:

  • The network ID (the first three octets) that indicates which network the device is on.

  • The host ID (the fourth octet) that identifies the specific device on that network.

For example, if your home network has a 192.168.1.1 address, 192.168.1 is the network ID, while the final octet (1) is the host ID. In most networks, the router gets the .1 value by default.

IPv4 enables the creation and use of 4,294,967,296 unique addresses (more commonly expressed as 2^32). In the 1980s and 1990s, over 4 billion available addresses seemed sufficient to meet the demand of the online world. However, it quickly became clear that a shortage was coming.

Nowadays, there are over 7.75 billion people worldwide, and most of us use two or more smart devices. Just over four billion IP addresses are no longer enough, so IT experts must "trick" devices into reusing the same addresses.

The most common technique for reusing IPv4 addresses is Network Address Translation (NAT). NAT enables you to represent a group of devices with a single IP address, which conserves bandwidth and slows down the depletion of IP addresses.

IPv4 addresses explained

IPv4 Features

Here are the main features of IPv4:

  • Creates 32-bit IP addresses.

  • Addresses use four 1-byte decimal numbers separated by a dot, a format that a human can easily read and even remember.

  • Connectionless protocol.

  • Requires small amounts of memory to store address info in the network.

  • Supported by nearly all devices and websites on the Internet.

  • Offers video libraries and conferences.

  • Enables the creation of a simple virtual communication layer over diversified devices.

What Is IPv6?

IPv6 is the latest Internet Protocol version and the successor to IPv4. IPv6 aims to fulfill the need for more IP addresses, the main issue of the previous IP. Another common name for IPv6 is IPng (Internet Protocol next generation).

Unlike its predecessor, IPv6 uses 128-bit hexadecimal IP addresses. This model enables 2^128 unique addresses (over 340 undecillion, which is 340 with 36 zeros).

IPv6 addresses are significantly longer than IPv4 variants (eight 16-bit blocks with groups of four symbols, often called hextets or quartets) and are alphanumeric. Also, whereas IPv4 relies on periods for formatting, IPv6 uses colons, such as in this example:

<kbd>2001:0db8:0000:0001:0000:ff00:0032:7879</kbd>

The model omits leading zeros (like in IPv4), and you'll sometimes find IP addresses that have a double colon (::) that designate any number of 0 bits (such as 1201:2db7::fa00:0040:6669, in which the third, fourth, and fifth hextets are 0000).

While IPv6 is more sustainable than IPv4, the majority of the Internet still uses IPv4. Upgrading all the routers, servers, and switches that have used IPv4 for decades takes a lot of time and money. Compatibility is also a concern, which is why we're seeing a rise in IPv4-to-IPv6 conversion techniques like:

  • Dual stacking that enables a device to run both protocol types at the same time.

  • IPv6 tunnels that allow private networks to communicate with each other even if they use different IP versions.

While functional, IP conversions create flaws that can lead to network security risks, cyber attacks, and data breaches. Ideally, a network should rely solely on IPv6, which is bound to become the norm in the coming years.

IPv6 addresses explained

IPv6 Features

Here are the main features of IPv6:

  • A 128-bit hexadecimal address scheme.

  • Both statefull and stateless configurations.

  • Auto-configuration capabilities.

  • Support for Quality of Service (QoS), a.k.a. flow labeling.

  • Better multicast routing and simpler header format than IPv4.

  • End-to-end connectivity at the IP layer, so there's no need for NAT, one of the most popular workarounds for conserving IPv4 addresses.

  • Integrated Internet Protocol Security (IPSec) with built-in authentication, encryption, and privacy support.

IPv4 vs IPv6: Table Comparison

The table below offers an in-depth IPv4 vs IPv6 comparison:

Point of comparisonIPv4IPv6
Size of IP address32-bit (4 bytes)128-bit (16 bytes)
Number of available IP addresses4.3 billion (must reuse and mask addresses)340 undecillion (every device can have a unique address)
IP address notationDecimal address, 4 fields (octets) separated by dots (.)Alphanumeric address, 8 fields (hextets or quartets) separated by colons (:)
Main selling pointWidely supported and easy to useVirtually unlimited number of IP addresses
IP address lifetimeNot an applicable conceptTwo lifetimes: preferred and valid (preferred lifetime is always smaller or equal to valid)
Address prefixSometimes used to designate network from host portion (written as /nn suffix on the presentation form of address)Used to designate the subnet prefix of an address (written as /nnn)
ConfigurationDHCP or manual configurationStateless address auto-configuration (via Internet Control Message Protocol version 6 (ICMPv6) or DHCPv6)
Number of header fields12 (length of 20-60 bytes)8 (fixed length of 40 bytes)