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:
- take the mac address: for example 52:74:f2:b1:a8:7f
- throw ff:fe in the middle: 52:74:f2:ff:fe:b1:a8:7f
- reformat to IPv6 notation 5274:f2ff:feb1:a87f
- convert the first octet from hexadecimal to binary: 52 -> 01010010
- invert the bit at position 6 (counting from 0): 01010010 -> 01010000
- convert octet back to hexadecimal: 01010000 -> 50
- replace first octet with newly calculated one: 5074:f2ff:feb1:a87f
- prepend the link-local prefix: fe80::5074:f2ff:feb1:a87f
- done!
No comments:
Post a Comment