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
DNS Resolver Example
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
Full Format with Uppercase
Unspecified Address (All Zeros)
::1)
Compressed Ending
Compressed Beginning
Compressed Middle
Leading Zero Compression
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
IPv4-Mapped IPv6
Compressed IPv6 Ending
Compressed IPv6 Middle
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
Quick Usage
result = ipmapper.lookup("8.8.8.8")
print(result["country_name"]) # "United States of America"