IPv4 vs IPv6: Differences Explained

Every device that connects to a network, from laptops and smartphones to smartwatches, IoT sensors, and home automation gear, needs an IP address to identify itself and exchange data. Devices communicate through several network protocols, with TCP and IP being the most frequently used. Each device on the network must have an IP address that identifies it.
This article explains the Internet Protocol and how IPv6 differs from IPv4.
What is IP (Internet Protocol)?
Being humans, we identify and communicate with each other using our names. Likewise, in the computing world, devices use IP addresses to identify and interact with each other. A common language used by all computing devices to communicate with each other is known as a protocol. Akin to human languages, the protocol also has a set of rules that formats and processes the data.

The Internet Protocol (IP) is a set of rules that specifies addressing and routing the data between computers. It is mostly used with network transport protocols, such as TCP and UDP.
The Internet exists today because of this unique addressing pattern. The IANA manages the IP address ranges for networks and sites that connect to the Internet. However, if we run an isolated local network, we can assign numbers according to our preference. The sections below break down each version and then compare them side by side.
IPv4
The first major version of Internet Protocol (IP) is version 4 (IPv4). It uses a 32-bit addressing scheme split into four 8-bit numbers known as octets. For example, 192.0.2.1 is an IPv4 address written in dotted-decimal notation. IPv4 addresses can be configured manually or assigned automatically by a DHCP server.
To test the local IPv4 network stack with an address that is always available, use the ping
command with the loopback address:
ping -c 1 127.0.0.1PING 127.0.0.1 (127.0.0.1) 56(84) bytes of data.
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.031 msThe response confirms that IPv4 is working locally. The reported response time varies by system.
An IPv4 address contains network and host portions, with the prefix length determining where the division occurs. Modern networks use Classless Inter-Domain Routing (CIDR), such as /24, instead of the original classful addressing system. The historical classes are shown below because you may still encounter the terminology in older documentation and tool output.
The calculation of subnet involves a few mathematical rubrics behind the screen. To ease our computation, we can use tools like ipcalc or subnetcalc for IPv4 subnetting. The below snippets shows how to use the tools:
ipcalc 110.0.20.18/24Address: 110.0.20.18 01101110.00000000.00010100. 00010010
Netmask: 255.255.255.0 = 24 11111111.11111111.11111111. 00000000
Wildcard: 0.0.0.255 00000000.00000000.00000000. 11111111
=>
Network: 110.0.20.0/24 01101110.00000000.00010100. 00000000
HostMin: 110.0.20.1 01101110.00000000.00010100. 00000001
HostMax: 110.0.20.254 01101110.00000000.00010100. 11111110
Broadcast: 110.0.20.255 01101110.00000000.00010100. 11111111
Hosts/Net: 254 Class Asubnetcalc 192.168.10.15/24Address = 192.168.10.15
11000000 . 10101000 . 00001010 . 00001111
Network = 192.168.10.0 / 24
Netmask = 255.255.255.0
Broadcast = 192.168.10.255
Wildcard Mask = 0.0.0.255
Hosts Bits = 8
Max. Hosts = 254 (2^8 - 2)
Host Range = { 192.168.10.1 - 192.168.10.254 }
Properties =
- 192.168.10.15 is a HOST address in 192.168.10.0/24
- Class C
- Private
GeoIP Country = Unknown (??)
DNS Hostname = (Name or service not known)Usually, IP addresses are given to the end host machine and router gateway interface, as illustrated below.

Here, the traffic from Machine A (10.235.64.58) hits the router gateway interface (10.235.64.57) at the left side of the internet cloud. It reaches Google Server gateway through Internet routing and finally to the destination server.
To identify the network interface IP you can use commands such as ip
, hostname, or the older ifconfig
, which is deprecated on current distributions but still widely available.
ifconfig ens160ens160: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.235.64.58 netmask 255.255.255.252 broadcast 10.235.64.59
inet6 fe80::fc7f:d8da:a969:1c1d prefixlen 64 scopeid 0x20<link>
ether 00:0c:29:23:6f:30 txqueuelen 1000 (Ethernet)
RX packets 35607241 bytes 34540488400 (34.5 GB)
RX errors 0 dropped 12 overruns 0 frame 0
TX packets 24701952 bytes 15008379564 (15.0 GB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0hostname -I10.235.64.58IPv4 includes special-purpose addresses such as 0.0.0.0 and 127.0.0.1. The unspecified address 0.0.0.0 means no particular address in contexts such as socket binding. The prefix 0.0.0.0/0 represents the default route, while 127.0.0.1 is the loopback address.
In the below snippet, we will use netstat
to see the Kernel IP routing table with the default route for that network. The flag ‘U’ represents that the network route is UP, whilst G signifies that the network route is the network gateway.
netstat -rn | grep ens160Kernel IP routing table
Destination Gateway Genmask Flags MSS Window irtt Iface
0.0.0.0 10.235.64.57 0.0.0.0 UG 0 0 0 ens160
10.235.64.56 0.0.0.0 255.255.255.252 U 0 0 0 ens160Usually, the IPv4 datagram consists of a header field with 20 bytes, options field, and data fields with a variable length. The sample packet format is shown below.

Below, Wireshark capture helps to decipher the packet header information from the live traffic.

IPv6
Internet Protocol version 6 is the newer version of the Internet Protocol, designed to replace IPv4 and solve its address exhaustion problem. Google’s IPv6 statistics show that adoption continues to grow, although IPv4 still carries a large share of Internet traffic.
The IPv6 address is 128 bits (16 bytes) using 32 hexadecimal digits, whilst these digits are further divided into eight groups of four digits each for ease of management. A brief illustration is shown below.

IPv6 addresses follow a few basic notation rules:
- Hexadecimal letters are case-insensitive. For example,
ab41andAB41are equivalent. - Leading zeros in a group can be omitted. For example,
001acan be written as1a. - One consecutive sequence of all-zero groups can be replaced with
::. This compression can appear only once in an address.
For instance, consider the IPv6 address 45ab:0000:a179:0000:0000:c1c0:abcd:0876
First, remove the leading zeros:
45ab:0:a179:0:0:c1c0:abcd:876Next, compress the longest sequence of zero groups:
45ab:0:a179::c1c0:abcd:876There are three types of IPv6 addresses: Unicast, Multicast, and Anycast. The unicast address is the single network interface and packets delivered to that specific interface. Additionally, unicast addresses have local(link-local) and global scope levels. Multicast address is the group interfaces to which the packets get delivered. Anycast address is the group interface and packet delivered to the nearest interface.
Few well-known addresses are tabulated below.
subnetcalc 2001:4860:4860::8888/64Address = 2001:4860:4860::8888
2001 = 00100000 00000001
4860 = 01001000 01100000
4860 = 01001000 01100000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
0000 = 00000000 00000000
8888 = 10001000 10001000
Network = 2001:4860:4860:: / 64
Netmask = ffff:ffff:ffff:ffff::
Wildcard Mask = ::ffff:ffff:ffff:ffff
Hosts Bits = 64
Max. Hosts = 18446744073709551616 (2^64 - 1)
Host Range = { 2001:4860:4860::1 - 2001:4860:4860:0:ffff:ffff:ffff:ffff }
Properties =
- 2001:4860:4860::8888 is a HOST address in 2001:4860:4860::/64
- Global Unicast Properties:
+ Interface ID = 0000:0000:0000:8888
+ Sol. Node MC = ff02::1:ff00:8888
GeoIP Country = United States (US)
DNS Hostname = dns.googleAgain, the IPv6 packet has both a header and payload. The header size is fixed at 40 bytes, with the source and destination addresses taking 32 bytes. The sample packet format is shown below.

Although IPv6 has many advantages, it cannot replace IPv4 overnight. Both protocol versions have to coexist during the migration, so service providers offer dual-stack support, where a network interface can understand both IPv4 and IPv6 packets.
There are few smart transition mechanisms, namely IPv6 Tunneling, IPv4 mapped IPv6 addresses, etc. The former encapsulates the IPv6 packet in IPv4, whilst the latter maps the IPv6 to IPv4 addresses in the dual-stack implementations.
IPv4 vs IPv6: Quick Comparison
Conclusion
IPv4 and IPv6 solve the same problem with different addressing schemes, and the move toward IPv6 is driven by the exhaustion of the IPv4 address space. If you administer a network, learning to read and configure both address types is worth the time, since dual-stack setups will stay common for years to come.
Tags
Linuxize Weekly Newsletter
A quick weekly roundup of new tutorials, news, and tips.
About the authors
Sriram Ramanujam
A seasoned Global Network Automation Architect with 10+ years of rich industry experience in developing scalable solutions for network automation, engineering design, operation and telemetry.
View author page