seberik
seberik

Reputation: 415

IPv6 zero compression

When using zero-compression on the following IPv6 address

2001:0DB8:0000:CD30:0000:0000:0000:0000/60

Why is this not correct:

2001:DB8::CD30::/60

... while this is:

2001:DB8:0:CD30::/60

Upvotes: 3

Views: 1428

Answers (3)

Angs
Angs

Reputation: 1655

The reason is that :: is used to shorten multiple zeros in the 16-bit address field.

In your example 2001:0DB8:0000:CD30:0000:0000:0000:0000/60, it only has multiple 0s in the 16-bit field at the suffix, the 0000 in 2001:0DB8:0000:CD30: is just one 16-bit field and you'd just use 0 to shorten it.

More interesting question: How would you shorten this2001:0000:0000:CD30:0000:0000:0000:0000/60?

It is defined in the standard:

In addition, Section 2.2 of [RFC4291] notes,

  'The "::" can only appear once in an address.'

What it means that the address can be written as either: 2001:0:0:CD30::/60 OR 2001::0:CD30:0:0:0:0/60.

Both are valid, but I'd prefer the first representation since the purpose of zeroco mpression is to shorten the address where the first representation is shorter.

Upvotes: 0

Jeremy Visser
Jeremy Visser

Reputation: 6621

Because it is ambiguous.

The address 2001:DB8::CD30:: could be expanded in any of the following possibilities:

2001:DB8:0:CD30:0:0:0:0

2001:DB8:0:0:CD30:0:0:0

2001:DB8:0:0:0:CD30:0:0

2001:DB8:0:0:0:0:CD30:0

Upvotes: 1

MrTux
MrTux

Reputation: 34002

Zero compression can only be made once. The reason for this is, that the IPv6 address is not unique any more otherwise.

Take your example 2001:DB8::CD30::/60 will it expand to

2001:0DB8:0000:0000:0000:CD30:0000:0000/60

or

2001:0DB8:0000:0000:CD30:0000:0000:0000/60

or

2001:0DB8:0000:CD30:0000:0000:0000:0000/60

...?

If only one "::" is used, the result will always be unique as there is only one possible fixed number of zeros to be inserted.

Upvotes: 5

Related Questions