Project

General

Profile

Actions

The ungleich IPv6 book » History » Revision 2

« Previous | Revision 2/5 (diff) | Next »
Ahmed Bilal, 06/10/2019 01:20 PM
Content Added


The ungleich IPv6 book

A resource for IPv6 beginners

Status

IN PROGRESS

Tools needed

You would need the following things to follow this Wiki.
  1. A Linux Distribution
  2. sipcalc utility
  3. A Hex Calculator (Google Search will suffice)

Understanding networks, network masks

Sample IPv6 Address 2001:0db8:85a3:0000:0000:8a2e:0370:7334

IPv6 address have a size of 128 bits while IPv4 have a size of 32 bits.

IPv6 address is divided into 8 groups each made up of 4 hexadecimal digits. (Each hexadecimal digit takes 1 nibble or 4 bits). So, each group takes 2 bytes (16 bits).

Address Compression

We can compress the IPv6 address. Following are some simple rules

1. Leading zeroes in a group may be omitted, but each group must retain at least one hexadecimal digit. Thus, the example address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 can be written as:

2001:db8:85a3:0:0:8a2e:370:7334

2. One or more consecutive groups containing zeros only may be replaced with a single empty group, using two consecutive colons (::).[1] The substitution may only be applied once in the address, however, because multiple occurrences would create an ambiguous representation. Thus, the example address 2001:0db8:85a3:0000:0000:8a2e:0370:7334 can be further simplified:

2001:db8:85a3::8a2e:370:7334

The localhost (loopback) address, 0:0:0:0:0:0:0:1, and the IPv6 unspecified address, 0:0:0:0:0:0:0:0, are reduced to ::1 and ::, respective

Address Ranges

Just to check we are on same page. What is the expanded form of 2a0a:e5c1:100::/48? Answer: 2a0a:e5c1:100:0:0:0:0:0

The size of a block of addresses is specified by writing a slash (/) followed by a number in decimal whose value is the length of the network prefix in bits. For example, an address block with 48 bits in the prefix is indicated by /48. Such a block contains 2^(128 − 48) = 2^80 addresses. The smaller the value of the network prefix, the larger the block.

Cool Tricks with sipcalc

Run the following command on your terminal

sipcalc 2a0a:e5c1:100::/40

[meow@meow-pc ~]$ sipcalc 2a0a:e5c1:100::/40
-[ipv6 : 2a0a:e5c1:100::/40] - 0

[IPV6 INFO]
Expanded Address    - 2a0a:e5c1:0100:0000:0000:0000:0000:0000
Compressed address    - 2a0a:e5c1:100::
Subnet prefix (masked)    - 2a0a:e5c1:100:0:0:0:0:0/40
Address ID (masked)    - 0:0:0:0:0:0:0:0/40
Prefix address        - ffff:ffff:ff00:0:0:0:0:0
Prefix length        - 40
Address type        - Aggregatable Global Unicast Addresses
Network range        - 2a0a:e5c1:0100:0000:0000:0000:0000:0000 -
              2a0a:e5c1:01ff:ffff:ffff:ffff:ffff:ffff

If we subtract the network range

0x2a0ae5c101ffffffffffffffffffffff - 0x2a0ae5c1010000000000000000000000

How many addresses we get? 2^88. We can also get the same result by 2^(128 - network bits) = 2^(128 - 40) = 2^88.

Similarly, How many addresses we get if we have 2a0a:e5c1:100::/48 network?

Answer: 2^(128-48) = 2^80. Good.

Now, let me ask you a slightly different question. How many 2a0a:e5c1:100::/48 networks can we fit into 2a0a:e5c1:100::/40 network?

Run the following command on your terminal

sipcalc 2a0a:e5c1:100::/40
then
sipcalc 2a0a:e5c1:100::/48

[meow@meow-pc ~]$ sipcalc 2a0a:e5c1:100::/40
-[ipv6 : 2a0a:e5c1:100::/40] - 0

[IPV6 INFO]
Expanded Address    - 2a0a:e5c1:0100:0000:0000:0000:0000:0000
Compressed address    - 2a0a:e5c1:100::
Subnet prefix (masked)    - 2a0a:e5c1:100:0:0:0:0:0/40
Address ID (masked)    - 0:0:0:0:0:0:0:0/40
Prefix address        - ffff:ffff:ff00:0:0:0:0:0
Prefix length        - 40
Address type        - Aggregatable Global Unicast Addresses
Network range        - 2a0a:e5c1:0100:0000:0000:0000:0000:0000 -
              2a0a:e5c1:01ff:ffff:ffff:ffff:ffff:ffff
[meow@meow-pc ~]$ sipcalc 2a0a:e5c1:100::/48
-[ipv6 : 2a0a:e5c1:100::/48] - 0

[IPV6 INFO]
Expanded Address    - 2a0a:e5c1:0100:0000:0000:0000:0000:0000
Compressed address    - 2a0a:e5c1:100::
Subnet prefix (masked)    - 2a0a:e5c1:100:0:0:0:0:0/48
Address ID (masked)    - 0:0:0:0:0:0:0:0/48
Prefix address        - ffff:ffff:ffff:0:0:0:0:0
Prefix length        - 48
Address type        - Aggregatable Global Unicast Addresses
Network range        - 2a0a:e5c1:0100:0000:0000:0000:0000:0000 -
              2a0a:e5c1:0100:ffff:ffff:ffff:ffff:ffff

Answer: 2^(48 - 40) = 2^8 = 256. So, you can put 256 /48 networks in /40.

Updated by Ahmed Bilal over 5 years ago · 2 revisions