✦ For everyone, free.

Practical knowledge for real and everyday life

Home

IPv4 and IPv6 Addressing

IPv4 and IPv6 addressing define how devices identify and communicate over networks, forming the foundation of modern internet connectivity.

IPv4 and IPv6 Addressing refers to the system and methodology used to assign unique identifiers to devices on a network, enabling them to communicate over the Internet or any IP-based network. These addresses serve as logical locations for devices, facilitating routing and data exchange at the network layer of the OSI model.


IPv4 Addressing

IPv4 (Internet Protocol version 4) is the fourth version of the Internet Protocol and uses a 32-bit address format, which allows for approximately 4.3 billion unique addresses. An IPv4 address consists of four octets (8 bits each), typically represented in decimal form separated by dots, for example:

192.168.1.1

Each octet ranges from 0 to 255, and the entire address space is divided into network and host portions by a subnet mask, which defines how many bits are used for the network.

Structure and Classes

IPv4 addresses are traditionally categorized into five classes (A through E), though modern usage often relies on Classless Inter-Domain Routing (CIDR) for more efficient allocation.

ClassFirst Octet RangeNetwork BitsHost BitsNumber of NetworksHosts per NetworkUsage
A1–12682412616,777,214Large networks
B128–191161616,38465,534Medium-sized networks
C192–2232482,097,152254Small networks
D224–239Multicast Multicasting
E240–255Reserved Experimental, future use

Subnetting and CIDR

Subnetting divides a network into smaller sub-networks to improve routing efficiency and security. CIDR uses a suffix notation to denote the number of bits in the network prefix, e.g., 192.168.1.0/24 indicates that the first 24 bits are the network part.

The subnet mask is often written in dotted decimal, e.g., 255.255.255.0 for a /24 network.

Private and Public Addresses

Certain IPv4 ranges are reserved for private networks and are not routable on the public Internet:

  • 10.0.0.0 – 10.255.255.255 (10/8 prefix)
  • 172.16.0.0 – 172.31.255.255 (172.16/12 prefix)
  • 192.168.0.0 – 192.168.255.255 (192.168/16 prefix)

These ranges are used inside local area networks (LANs) and require Network Address Translation (NAT) to communicate externally.


IPv6 Addressing

IPv6 (Internet Protocol version 6) is the successor of IPv4, designed to address the exhaustion of IPv4 addresses and introduce improvements in routing, security, and autoconfiguration. IPv6 uses 128-bit addresses, allowing for approximately 3.4 x 10^38 unique addresses.

An IPv6 address is represented as eight groups of four hexadecimal digits separated by colons, for example:

2001:0db8:85a3:0000:0000:8a2e:0370:7334

Leading zeros in any group can be omitted, and one sequence of consecutive zeros can be compressed using a double colon ::, but only once per address.

Structure

IPv6 addresses are divided into several fields used for routing and addressing:

  • Global Routing Prefix: Assigned by an ISP, used to identify a specific network.
  • Subnet ID: Used within an organization to identify subnets.
  • Interface Identifier: Usually 64 bits, derived from the network interface hardware or generated randomly.

Address Types

IPv6 defines several address types:

  • Unicast: Identifies a single interface; packets sent here are delivered to one device.
  • Multicast: Identifies a group of interfaces; packets are delivered to all in the group.
  • Anycast: Assigned to multiple interfaces, but packets are routed to the nearest one.

Unlike IPv4, IPv6 does not use broadcast addresses; multicast replaces broadcast functionality.

IPv6 Address Scopes

IPv6 addresses have scopes defining their reachability:

  • Link-Local: Begins with fe80::/10, used for communication on the local link.
  • Unique Local Addresses (ULA): Begins with fc00::/7, used for private networks similar to IPv4 private addresses.
  • Global Unicast: Routable on the global Internet, typically beginning with 2000::/3.

Autoconfiguration

IPv6 supports Stateless Address Autoconfiguration (SLAAC), allowing devices to self-configure addresses without a DHCP server, using Router Advertisements to generate interface identifiers.


Address Assignment and Configuration in Alpine Linux

In Alpine Linux, IPv4 and IPv6 addresses are configured through network interface configuration files or commands.

Using /etc/network/interfaces

Example static IPv4 configuration:

iface eth0 inet static
    address 192.168.1.10
    netmask 255.255.255.0
    gateway 192.168.1.1

Example static IPv6 configuration:

iface eth0 inet6 static
    address 2001:db8::10
    netmask 64
    gateway 2001:db8::1

Using ip command

Assign IPv4 address:

ip addr add 192.168.1.100/24 dev eth0

Assign IPv6 address:

ip -6 addr add 2001:db8::100/64 dev eth0

Bring interface up:

ip link set eth0 up

Routing and Address Resolution

IPv4 and IPv6 both use routing tables to determine the path to a destination address. Routing protocols and static routes direct packets based on prefix matching and metrics.

Address Resolution Protocol (ARP) and Neighbor Discovery (ND)

  • IPv4 uses ARP to map IPv4 addresses to MAC addresses on the local network.
  • IPv6 uses Neighbor Discovery (ND), which performs similar functions but also manages router discovery and address autoconfiguration, using ICMPv6 messages.

Summary of Differences Between IPv4 and IPv6 Addressing

FeatureIPv4IPv6
Address length32 bits128 bits
Address notationDotted decimalHexadecimal colon-separated
Address space size~4.3 billion addresses~3.4 × 10^38 addresses
Address typesUnicast, multicast, broadcastUnicast, multicast, anycast
Broadcast supportYesNo (replaced by multicast)
Address configurationManual, DHCPManual, DHCPv6, SLAAC
Private address rangesDefined ranges (e.g., 192.168.x.x)Unique Local Addresses (ULA)
Address exhaustionLimited, running outVast, practically unlimited
Header complexitySimplerMore complex, with extension headers

IPv4 and IPv6 addressing form the fundamental basis for identifying devices and enabling communication in modern IP networking, with IPv6 providing enhancements and scalability to meet the growing demands of the Internet. Understanding their formats, addressing schemes, and configuration methods is essential for managing Alpine Linux networking and general IP infrastructure.