Read and write IPv6 addresses correctly

short · 30 min · Objective 1.8

Task

Compress, expand and classify a set of IPv6 addresses, then generate a link- local address from a MAC using EUI-64. The notation rules are examinable in their own right, and a compression mistake makes every later answer wrong.

Steps

  1. Compress these fully, applying both rules: drop leading zeros in each group, and replace one run of all-zero groups with ::.
  2. 2001:0db8:0000:0000:0000:ff00:0042:8329
  3. fe80:0000:0000:0000:0204:61ff:fe9d:f156
  4. 2001:0db8:0000:0001:0000:0000:0000:0001
  5. That third one is the trap. Two separate zero runs exist and only the longer may be replaced. Write down which run you compressed and why.
  6. Expand these back to full form: ::1, fe80::1, 2001:db8::8a2e:370:7334.
  7. Classify each by prefix: global unicast (2000::/3), link-local (fe80::/10), unique local (fc00::/7), multicast (ff00::/8), loopback (::1). The 2001:db8:: addresses are global unicast in form, inside the block 2001:db8::/32 reserved for documentation by RFC 3849 -- IPv6's version of 192.0.2.0/24, never routed. They are not unique local: that is fc00::/7 only, and in practice fd00::/8.
  8. Derive the EUI-64 interface identifier for MAC 00:1a:2b:3c:4d:5e: split it in half, insert fffe in the middle, and flip the seventh bit of the first octet. State the resulting link-local address.

Verify

python3 -c "
import ipaddress
for a in ('2001:0db8:0000:0000:0000:ff00:0042:8329','fe80:0000:0000:0000:0204:61ff:fe9d:f156','2001:0db8:0000:0001:0000:0000:0000:0001','::1','fe80::1','2001:db8::8a2e:370:7334'):
    i = ipaddress.ip_address(a)
    kind = ('loopback' if i.is_loopback else 'link-local' if i.is_link_local
            else 'multicast' if i.is_multicast
            else 'unique local' if i in ipaddress.ip_network('fc00::/7')
            else 'global unicast (documentation)' if i in ipaddress.ip_network('2001:db8::/32')
            else 'global unicast')
    print(f'{i.compressed:<28}{i.exploded:<42}{kind}')
mac = '00:1a:2b:3c:4d:5e'.split(':')
b = int(mac[0],16) ^ 0x02
eui = f'{b:02x}{mac[1]}:{mac[2]}ff:fe{mac[3]}:{mac[4]}{mac[5]}'
print('EUI-64 link-local:', ipaddress.ip_address('fe80::' + eui))
"

Six addresses, each shown compressed and expanded, plus the EUI-64 result. The third address must compress to 2001:db8:0:1::1 — if yours has the :: in the first zero run, you replaced the shorter one.

Notes

The two rules that catch people out: :: may appear only once in an address, and when two zero runs are equal in length the convention is to compress the leftmost. Everything else is leading-zero suppression, which is always safe.

EUI-64 is worth doing by hand once because of that flipped bit. The seventh bit is the universal/local flag, and inverting it is what turns a globally unique MAC-derived identifier into one marked as locally assigned. Privacy extensions mean most modern hosts do not use EUI-64 at all — but the exam still asks.

This is an independent study companion for CompTIA Network+ and is not produced by or endorsed by CompTIA.