Free study tool
IPv6 compression and expansion
Useful for CompTIA Network+
Compress, expand, and identify
Full or shortened form, upper or lower case.
Compressed: 2001:db8::8:800:200c:417a
- Compressed (RFC 5952)
- 2001:db8::8:800:200c:417a
- Expanded
- 2001:0db8:0000:0000:0008:0800:200c:417a
- Address type
- Global unicast
- Matching prefix
- 2000::/3
How it compresses
- 1Write the hex digits in lowercase (RFC 5952 section 4.3).
- 2Write out all eight 16-bit fields: 2001 0db8 0000 0000 0008 0800 200c 417a.
- 3Drop the leading zeros in each field: 2001 db8 0 0 8 800 200c 417a.
- 4All-zero fields: fields 3 to 4.
- 5Replace the longest run, fields 3 to 4, with ::.
- 6Result: 2001:db8::8:800:200c:417a
How it expands
- 1Pad every field to four hex digits: 2001 0db8 0000 0000 0008 0800 200c 417a.
- 2Result: 2001:0db8:0000:0000:0008:0800:200c:417a
Its type
- 1Expanded, the address is 2001:0db8:0000:0000:0008:0800:200c:417a.
- 2Its first 3 bits are 001.
- 3That matches 2000::/3: global unicast.
Sources
- RFC 4291, section 2.2: Text Representation of Addresses
IETF · An address is eight 16-bit hex fields; leading zeros in a field can be left out, and "::" stands for one or more zero fields, once per address.
- RFC 5952, section 4.1: Handling Leading Zeros in a 16-Bit Field
IETF · Leading zeros in each 16-bit field must be removed.
- RFC 5952, section 4.2.1: Shorten as Much as Possible
IETF · "::" must replace as many zero fields as it can.
- RFC 5952, section 4.2.2: Handling One 16-Bit 0 Field
IETF · "::" must not be used to shorten a single 16-bit zero field.
- RFC 5952, section 4.2.3: Choice in Placement of "::"
IETF · The longest run of zero fields is the one shortened, and when runs tie, the first one is.
- RFC 5952, section 4.3: Lowercase
IETF · The hex letters a to f must be written in lowercase.
- Internet Protocol Version 6 Address Space
IANA · 2000::/3 is allocated as global unicast; most of the remaining blocks are reserved by the IETF.
- RFC 3849, section 2: Documentation IPv6 Address Prefix
IETF · 2001:db8::/32 is reserved for documentation and examples.
Practice compression
Write this address in its shortest standard form
fd4d:2bd4:00f1:08a8:0000:000f:0000:0000
The compression rules
- Write hex digits in lowercase.
- Drop leading zeros in every field, so
0db8becomesdb8and0000becomes0. - Replace the longest run of two or more all-zero fields with
::. If two runs tie, shorten the first one. - Never use
::for a single zero field, and never use it twice, because then nobody could tell how many fields each one stands for.
Several shortened forms can name the same address, and all of them are valid input. RFC 5952 picks one of them as the form to write, so logs, documentation, and exam answers all match.
Common questions
- Can :: appear twice in one IPv6 address?
- No. It can appear only once, because two of them would make it impossible to know how many zero fields each one replaces.
- What kind of address starts with fe80?
- A link-local unicast address, from fe80::/10. Every IPv6 interface has one, and routers don't forward traffic sent to or from it.
- What is 2001:db8::?
- 2001:db8::/32 is reserved for documentation and examples (RFC 3849), which is why this tool's examples use it.
More free tools
IPv4 subnet calculator
Network, broadcast, usable range, and host count for any address and prefix, with the working shown.Subnetting practice
Unlimited subnetting questions. Answer, check, and see the block-size method worked through.Port and protocol reference
The well-known ports for CompTIA A+ and CompTIA Network+, each linked to its IANA registry entry.