The 3 Golden Rules of IPv6 Compression
If you follow these three rules, you will never format an IPv6 address incorrectly:
Rule 1: You can drop leading zeros in any block.
0001becomes10db8becomesdb80000becomes0
Rule 2: The :: can replace any contiguous blocks of all zeros.
fe80:0:0:0:0:0:0:1becomesfe80::1
Rule 3: You can only use :: ONCE per address.
- This is the most critical rule. If you use it twice, the computer cannot do the math to figure out how many zeros go in each spot.
- Invalid:
2001::abcd::1(The computer doesn’t know if this means 4 zero blocks then 2 zero blocks, or 2 zero blocks then 4 zero blocks). - Fix: If you have two separate chunks of zeros, you must use
::on the longest chunk, and use single0s for the other. Example:2001:0:0:abcd::1. (If the chunks are equal in length, standard practice is to compress the leftmost chunk).
Leave a Reply