Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert from MAC to IPv6

Tags:

ipv6

I would like to understand how to convert a MAC adress to IPv6. For example: 00:01:04:76:2A:5C Should become FE80::0201:04FF:FE76:2A5C

Could someone elaborate the conversion please ? We suppose an automatic configuration without random parameter for a local machin.

like image 295
Arkon Avatar asked Nov 28 '22 20:11

Arkon


1 Answers

Conversion step by step from a MAC address (48 bits) to a IPv6 address (128 bits):

  1. take the mac address: 52:74:f2:b1:a8:7f
  2. throw ff:fe in the middle: 52:74:f2:ff:fe:b1:a8:7f
  3. reformat to IPv6 notation 5274:f2ff:feb1:a87f
  4. convert the first octet from hexadecimal to binary: 52 -> 01010010
  5. invert the bit at index 6 (counting from 0): 01010010 -> 01010000
  6. convert octet back to hexadecimal: 01010000 -> 50
  7. replace first octet with newly calculated one: 5074:f2ff:feb1:a87f
  8. prepend the link-local prefix: fe80::5074:f2ff:feb1:a87f
like image 98
helloflash Avatar answered Jan 12 '23 09:01

helloflash