IPv4 Internet Protocol version 4

An IPv4 address has the format x.x.x.x, where x is called an octet and must be a decimal value between 0 and 255. Octets are separated by periods. An IPv4 address must contain three periods and four octets.

Valid IPv4 Examples

Standard Format
1.2.3.4
DNS Resolver Example
8.8.8.8
IPv4 Format Rules:
  • Four octets separated by three periods (dots)
  • Each octet must be a decimal value between 0 and 255
  • Canonical RFC 6943 notation omits leading zeros
  • No spaces or other characters are permitted

IPv6 Internet Protocol version 6

An IPv6 address can have either of the following two formats: Normal (Pure IPv6 format) or Dual (IPv6 plus IPv4 formats).

IPv6 Normal Format

An IPv6 (normal) address has the format y:y:y:y:y:y:y:y, where y is called a segment and can be any hexadecimal value between 0 and FFFF. The segments are separated by colons, not periods. An IPv6 normal address must have eight segments; however, a short form notation can be used for segments that are zero, or those that have leading zeros.

Valid IPv6 Normal Examples

Full Format
2001:db8:3333:4444:5555:6666:7777:8888
Full Format with Uppercase
2001:db8:3333:4444:CCCC:DDDD:EEEE:FFFF
Unspecified Address (All Zeros)
::
(implies all 8 segments are zero; loopback is ::1)
Compressed Ending
2001:db8::
(implies that the last six segments are zero)
Compressed Beginning
::1234:5678
(implies that the first six segments are zero)
Compressed Middle
2001:db8::1234:5678
(implies that the middle four segments are zero)
Leading Zero Compression
2001:0db8:0001:0000:0000:0ab9:C0A8:0102
Can be compressed to: 2001:db8:1::ab9:c0a8:102

IPv6 Dual Format

An IPv6 (dual) address combines an IPv6 and an IPv4 address and has the following format: y:y:y:y:y:y:x.x.x.x. The IPv6 portion of the address (indicated with y's) is always at the beginning, followed by the IPv4 portion (indicated with x's).

IPv6 Dual Format Rules

IPv6 Portion (y:y:y:y:y:y):
  • y is called a segment and can be any hexadecimal value between 0 and FFFF
  • Segments are separated by colons, not periods
  • Must have six segments, with short-form zero compression allowed
IPv4 Portion (x.x.x.x):
  • x is called an octet and must be a decimal value between 0 and 255
  • Octets are separated by periods
  • Must contain three periods and four octets

Valid IPv6 Dual Examples

Full Dual Format
2001:db8:3333:4444:5555:6666:1.2.3.4
IPv4-Mapped IPv6
::ffff:8.8.8.8
(standard IPv4-mapped IPv6 representation)
Compressed IPv6 Ending
2001:db8::123.123.123.123
(implies that the last four IPv6 segments are zero)
Compressed IPv6 Middle
2001:db8::1234:5678:5.6.7.8
(implies that the middle two IPv6 segments are zero)

Subnet Masks (IPv4) and Prefixes (IPv6)

Subnet masks (IPv4) and prefix lengths (IPv6) identify a range of IP addresses that are on the same network.

Aspect IPv4 Subnet Masks IPv6 Prefixes
Notation Dotted decimal (255.255.255.0) or CIDR (/24) CIDR notation only (/64, /128)
Purpose Define network and host portions Define network prefix length
Common Examples /24 (255.255.255.0), /16 (255.255.0.0) /64 (standard subnet), /128 (host route)
Address Space 32-bit address space 128-bit address space

Key Differences Summary

Feature IPv4 IPv6
Address Length 32 bits (4 bytes) 128 bits (16 bytes)
Format Dotted decimal (x.x.x.x) Hexadecimal with colons (y:y:y:y:y:y:y:y)
Number of Addresses ~4.3 billion (2³²) ~340 undecillion (2¹²&sup8;)
Separators Periods (dots) Colons
Compression Not supported Zero compression with "::"
Example 192.168.1.1 2001:db8::1

Need IP Geolocation in Your Code?

Use the open-source ipmapper Python package for fast, offline IP-to-country lookups without API keys or rate limits.

Python Installation
pip install ipmapper
Quick Usage
import ipmapper
result = ipmapper.lookup("8.8.8.8")
print(result["country_name"]) # "United States of America"
Live Edge API
curl "https://labs.anaskhan.me/ipmapper/api/lookup?ip=8.8.8.8"