Compress a Full Global Unicast Address
Compress a fully expanded Global Unicast IPv6 address. Learn the compression rules for removing leading zeros and applying :: notation correctly.
Detailed Explanation
Compressing a Global Unicast Address
Given the expanded address:
2001:0db8:0085:0000:0000:8a2e:0370:7334
The compressed form is:
2001:db8:85::8a2e:370:7334
Compression Rules Applied
Rule 1: Remove leading zeros from each group
| Before | After |
|---|---|
| 2001 | 2001 |
| 0db8 | db8 |
| 0085 | 85 |
| 0000 | 0 |
| 0000 | 0 |
| 8a2e | 8a2e |
| 0370 | 370 |
| 7334 | 7334 |
After Rule 1: 2001:db8:85:0:0:8a2e:370:7334
Rule 2: Replace the longest consecutive run of all-zero groups with ::
Groups 4-5 are the longest consecutive run of zeros (length 2), so they become :::
Result: 2001:db8:85::8a2e:370:7334
Important: Only One :: Allowed
If there are multiple runs of zeros, only the longest is replaced. If there is a tie, the leftmost run is replaced. You must never use :: more than once in an address.
Common Mistakes
| Incorrect | Correct | Problem |
|---|---|---|
| 2001:db8::85::1 | 2001:db8:0:85::1 | Two :: used |
| 2001:0db8::1 | 2001:db8::1 | Leading zero not removed |
Use Case
Understanding compression rules is essential when reading firewall rules, ACLs, routing tables, and log files. Different tools and operating systems may display the same address in different compressed forms, so knowing the canonical compression helps identify whether two representations refer to the same address.