Search

Ads

Showing posts with label network configuration with IPv6. Show all posts
Showing posts with label network configuration with IPv6. Show all posts

Tuesday, December 31, 2013

MAC address to IPv6 link-local address

MAC address to IPv6 link-local address

The math
Link-local IPv6 addresses are used as part of the IPv6 network auto-configuration process. Instead of getting an address via DHCP, a NIC will hop on the network with a link-local IPv6 address and with this will have to ability to do further configuration automatically (soliciting neighbors, router, et cetera).
This link-local IPv6 is inferred from the NIC’s mac address.
A mac address is 48 bits, an IPv6 address is 128 bits. Here’s the conversion process step by step:
  1. take the mac address: for example 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 position 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
  9. done!