Tag Archives: networking

Easy and quick ipv6

A few days back I had to work with ipv6. Being familiar with ipv4 I thought ipv6 would be straight forward for me. Well, it is but with a twist. To uncover the twists I will go through an overview of ipv6.

  • ipv6 128bit address where ipv4 is 32bit

Most obvious one, ipv6 provide more address than the ipv4, and it was introduced for this purpose.

  • ipv6 CIDR vs ipv4 CIDR

You may have seen ipv4 CIDR prefix, something like 192.168.1.0/24; and you will also see it in ipv6. But the main difference is that ipv6 does not mandate the use of the prefix by itself to recognize network address.

  • Address types

ipv6 has local, global, multicast and anycast address type where ipv4 has local, global, multicast and broadcast. Don’t think ipv4 broadcast is rebranded as anycast in ipv6.

local is for your link local and private network. They are the same in ipv6 and ipv4.

global is for the global routable address. They are also the same for both ipv6 and ipv4.

multicast is a special kind of address which can be used to group a number of systems and can be used to broadcast a particular information to all of the systems within that group. The main difference between ipv6 multicast and ipv4 multicast is that ipv6 multicast is intended to be routable.

Anycast is a special type of address which can be assigned to multiple systems (yes the same address). And any system can get the request from the requester. Maybe with ipv6 you can design your own load-balancing service by using the anycast scheme.

There is no notion of broadcast address in ipv6. Now the switch and router will have much more easier time while dealing with ipv6 packets.

  • Address shorting

It is not easy to write the full form ipv6 in hexadecimal format. Suppose you have the following ipv6 address

fe80:0000:0000:0000:2000:0aff:fe97:0e21

now imagine you have to type this whole address or even remember it! To ease our lives, there is an ipv6 address shorting rule,

Rule-1: replace consecutive block of 0 with “::”

Rule-2: remove leading 0 from the address within a block

By block, we mean the 4 hexadecimal value separated from next one by a ‘:’. So, in our example, it would be 8 blocks (8 blocks x 4 digits x 4 bits/digits = 128 bits).

Now applying rule-1, we can remove block 2,3,4 (considering left to right) with a single ‘::’ thus becoming –

fe80::2000:0aff:fe97:0e21

Applying rule-2, we can remove the 0 from 6th and 8th block we have

fe80::2000:aff:fe97:e21

So our new address has become more manageable

localhost in ipv6 is referred as ::1 in shortened form.

To represent ipv4 address in ipv6 we can simply use the last two block (32 bits) to represent the ipv4 address (32 bit) and use all zero in all other blocks, so if you have an ipv4 address like

192.168.1.254

Then your ipv6 address will be –

::c0a8:1fe

As c0 hex of 192, a8 is hex of 168, 01 is hex of 1 and fe is the hex of 254. And obviously, apply the rule-2 for address shortening.

 

To set ipv6 in your linux system use ip or ifconfig. and use ping6 tool to ping the ipv6 address with the following syntax –

ping6 <ipv6 addr>%<interface>

I will later post a blog on simple udp server talking with an udp client over the ipv6 network. And obviously with a little twist as well.

Leave a comment if you have any suggestion or question.