Skip to main content
CertLighthouse

Free study tool

IPv6 compression and expansion

Shorten any IPv6 address to the canonical RFC 5952 form, expand it back to all eight fields, and see what type of address it is. Then practice until it's automatic.

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

  1. 1
    Write the hex digits in lowercase (RFC 5952 section 4.3).
  2. 2
    Write out all eight 16-bit fields: 2001 0db8 0000 0000 0008 0800 200c 417a.
  3. 3
    Drop the leading zeros in each field: 2001 db8 0 0 8 800 200c 417a.
  4. 4
    All-zero fields: fields 3 to 4.
  5. 5
    Replace the longest run, fields 3 to 4, with ::.
  6. 6
    Result: 2001:db8::8:800:200c:417a

How it expands

  1. 1
    Pad every field to four hex digits: 2001 0db8 0000 0000 0008 0800 200c 417a.
  2. 2
    Result: 2001:0db8:0000:0000:0008:0800:200c:417a

Its type

  1. 1
    Expanded, the address is 2001:0db8:0000:0000:0008:0800:200c:417a.
  2. 2
    Its first 3 bits are 001.
  3. 3
    That matches 2000::/3: global unicast.

Sources

Practice compression

Write this address in its shortest standard form

fd4d:2bd4:00f1:08a8:0000:000f:0000:0000

The compression rules

  1. Write hex digits in lowercase.
  2. Drop leading zeros in every field, so 0db8 becomes db8 and 0000 becomes 0.
  3. Replace the longest run of two or more all-zero fields with ::. If two runs tie, shorten the first one.
  4. 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.

Practice that remembers where you left off

The CertLighthouse app will have these generators built in, with your progress saved and questions aimed at what you miss most. It's in development now.