MAC address to IPv6 link-local address online converter

The converter

It can also be addressed directly via:
for all your API needs.

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 infered 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 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
  9. done!

Going the other way

A converter to do the same operation in reverse is available here.


There have been a few interesting comments on this post, I encourage you to read them if you want to learn more about this mechanism. Specifically:

72 Replies to “MAC address to IPv6 link-local address online converter”

  1. In case someone is looking for this in bash:

    mac2ipv6() {
    	local mac=$1 ; \
    	echo $mac | \
    	tr '-' ':' | \
    	tr '[:upper:]' '[:lower:]' | \
    	awk -F: '{printf "fe80::%s%x%s:%sff:fe%s:%s%s\n", substr($1,1,1), xor(strtonum("0x"substr($1,2,1)),2), $2, $3, $4, $5, $6}'
    1. If someone gets an error:

      function xor never defined
      function strtonum never defined
      Call to undefined function

      Install gawk will fix this.

  2. Hi Ben, thank you for this useful tool. However, I found my machine (and several others that I have tried) don’t seem to have the link-local address that this tool generates.
    Here’s my example mac address: 00:d8:61:5d:55:ce, generating fe80::2d8:61ff:fe5d:55ce
    And here’s what `ip addr` generates:
    `inet6 fe80::6ac2:6911:27c6:f4cf/64 scope link noprefixroute
    valid_lft forever preferred_lft forever`
    I am not quite sure why. Is this address different from the link local address?
    Thank you for your help.

  3. When I put in my MAC address the results on the page don’t match what’s in the link local address on my computer.

  4. ipconfig /all

    you will see ‘Physical Address’ = MAC address

    P.S: thanks for your input Ben, way to be a leader :p

    1. Read the question, the guy wants the mac derived form the link local, not using a local command. So I’m sitting there thinking just reverse the freaking steps, I ain’t doing that for you. Many people don’t want to commit to the slightest amount of work and would much rather have someone else do it for them.

      Hence my response 🙂

      P.S.: read the original question :p

    1. It means you start counting bits at 0 from left to right, when you’re at number 6 you flip the bit (if it’s a 0 it becomes a 1 and vice versa).

  5. Hey,
    can please put the Skript on github or something like that. I need that for a little project and don’t want to use your api because of reasons. I tried everything in PHP but I’ve failed 🙁

    1. I’d rather not unfortunately, this is code ran on my web server and as a security rule of thumb, I don’t post it online in case there is a security flaw that is evading me. Did you post this with your actual email address? I could send you the meat of the script.

  6. So I use this tool and I do not get the same result as my Windows machine:

    Physical Address= 0A-00-27-00-00-00
    Link-local IPv6 Address= fe80::485:8161:2716:2a51

    How come?

  7. Ben .. Thanks for this … I was wondering if anyone has tried an excel formulae for this and if they would care to share.
    Use this a lot martin

  8. 52 -> 00110100

    00110100 + 00000010 = 00110110 -> 54
    another example:
    BC -> 10111100 + 00000010 = 10111110 -> BE

    1. Are you suggesting that my hex2bin is wrong? Cause I’m pretty sure it ain’t.

      Also “+ 00000010” is not the same thing a bit flipping. Care to explain further?

  9. Hello, isn’t the “7nth bit” fliped instead of the “6th bit” while converting a mac address into IP version 6?

    The person who wrote this guide says to flip the 1 that makes “52” into a “0”. I think they are wrong and if not please correct me by telling me why is it the 6th bit?

    The 7nth bit is fliped. So, if in the mac address there is a 1 in the 7nth position of the 8 bits, then the 1 becomes a 0 and if it is a 0 instead of a 1, it becomes a 1 in the 7nth position.

    Also many zero’s equal to :: “Double Coulmn?
    Thanks very much. Im a beginer to subnetting. Correct me if i am wrong. Im doing CCNA1 in cisco.

    1. From the instructions:
      “5. invert the bit at index 6 (counting from 0)”

      So yes, it’s the 7th bit but bit number 6 counting form 0 which is most likely how you’ll be counting if you script this stuff 🙂

      Many zeros do indeed equal to double column but this is for abbreviation purposes; meaning that fully writing each 0 is legal as well.

  10. how to find scope id in this case.. ? and what is the standard way of representing IPv6 link local address ?
    Is it nessesary to display scope id also if we want to display link local address somewhere ?

  11. Hey Ben…recent changes appear to have broken this page…it processes the request, but no results are returned, just an empty doc.

  12. Using the mac address B8:CA:3A:BF:3B:32 construct the link-local address with the
    MAC-to-EUI64 conversion process. Afterwards construct the IPv6 header (just the
    next header, source, and destination addresses) and the ICMPv6 Neighbor Solicitation
    (NS) header message format (type, code, target address). Then construct the IPv6
    header and Neighbor Advertisement (NA) message header (type,code, flags, and
    target address) as if the tentative address is duplicated on another node.

  13. i think you should call it the ‘7th’ bit , when you call it ‘6th’ — all kinds of confusion happens. Just saying that everyone else identifies that bit as 7th , also it is more logical to start your counting from one rather than zero. nice explanation though — worked for me.

    1. Well sure it’s the 7th bit, but it’s “the bit at index 6 (counting from 0)” for anything you’ll script because you’ll be dealing with an array. There is no such thing as “more logical to start your counting from one rather than zero” only conventions & standards. More intuitive maybe but not when you’re dealing with arrays. “Everybody is doing it” is not a valid argument.

      All in all as long as it’s labeled properly let’s worry about something else maybe?

      1. I just want to mention that as I’m still studying things, I was very glad for the comment about 6th/7th bit because I was starting to get very confused about how that worked, and actually visited the comments wondering if it was a typo. After reading the suggestion and reply above my post, I understand and was relieved at the clarification.

        Thanks for the great tool, too!

      2. Actually you are both wrong 😉 The bit to flip is bit 1. When counting bits you typically start from 0 (Ben is right) but you also start counting from the least significant bit.

        It’s all about conventions, obviously.

        1. Hah! Thanks for setting the record straight 🙂 I’m surprised this is the most controversial piece of the algorithm.

  14. Either I don’t follow the process correctly or the math is wrong for your conversion from a MAC address to an IPv6 address. Under “The Math,” you convert 52 to 01010010. I got 00110100. Please clarify. Thanks.

  15. Since Win Vista Windows uses random ipv6 link local addresses.
    You can force it to use EUI-64-based interface IDs with the command:
    netsh interface ipv6 set global randomizeidentifiers=disabled

  16. I enter my MAC address, but the calculated Link Local does not match what IPCONFIG shows my Link Local to be. It isn’t even close. The calculator follows what I have learned about creating the LL from the MAC, but what IPCONFIG shows on my machine is not even close to my MAC. Yes, I am looking at the entry for Link-local IPv6 Address and the starting block is FE80. Please explain if you will. TIA.

    1. Could you tell me what your MAC address is and what ipconfig gives you for a Link-Local address?

      Feel free to email them at if you have privacy concerns.

      I’m not a Windows guy but I think it uses some sort of tunneling adapter for IPv6, could it be that you’re looking at the MAC of your NIC and the LL address of that adapter? I’ll see if I can get my hands on a Windows box to see what things look like on this side of things.

  17. Thank you for providing this utility. I have found it be useful on several occasions. Would you please consider modifying to code so that both UPPER and lower case letters are accepted?

    1. Sure thing & done.

      I’ve only hacked it so everything is converted to lowercase but the end result is that both UPPER & lower cases are accepted.

      1. I was looking at the example you gave above. It says 52, but the binary adds up to 82. I could be wrong. But 01010010, 64 + 16 + 2 = 82, then inverted would equal 80. I am relatively new to this and could be wrong. But lets say it was 52, the binary would be 00110100, 32 + 16 + 4, then inverted would be 00110110, 32 + 16 + 4 + 2 would = 54. Am I right or am I still not understanding this stuff?

        1. I think you’re confusing hexadecimal with decimal. At no point in the operation are we dealing with decimal numbers.

          We go from hexadecimal to binary and then back from binary to hexadecimal.

          You are right that (bin)01010000 is (dec)80, but we’re not interested in (dec), what we want is (hex)50.

          Mac addresses & IPv6 addresses are hex based, IPv4 is decimal so there’s that to add confusion 🙂

          I hope this helps.

    1. Sure, this isn’t actually a construct of the MAC to link-local IPv6 mechanism per se. Based on RFC 4291 section 2.5.6, a link-local IPv6 address is just “fe80” followed by 54 null bits followed by the Interface ID. The trick here is that the “Interface ID” is not the same thing as a mac address, I think it’s meant to be the new mac address but I have yet to see one in the wild. As a result we also need to go from mac address to interface ID by flipping the bit in step 5 and adding ff:fe in the middle.

      More info here:

      If I see an interface ID anywhere I’ll have to update this guide a bit 🙂

      I hope this helps.

    2. Bit 6 in the MAC address “global/local” bit. When set to 1 it indicates that the MAC address was set manually by an administrator, rather than burned into the network card following the normal rules for vendor identification.

      Since people who wish to manually set an IPV6 address would likely use many zero’s, something like FE80::24 (FE80:0000:0000:0000:0000:0000:0000:0020), the conversion was designed that such manual address would indicate that it was generated from a locally administered mac address rather than a real MAC.

      1. When set to 1 it indicates that the MAC address was set manually by an administrator, rather than burned into the network card…


        FE80::24 (FE80:0000:0000:0000:0000:0000:0000:0020), the conversion was designed that such manual address would indicate that it was generated from a locally administered mac address rather than a real MAC.

        seem to be conflict with each other.

      2. Old post but its finally the path to why this bit is swapped.
        It is actually not the 6th bit of the MACadress first octet but the 2nd (b1) which distinguishes universal (0) and locally (1) administered addressing.
        It’s kinda neat. Every LLA that is generated from a MAC that was universal administered (set by manufacturer) has always a by 2 reduced first octet compared to the first one of the MAC.

Leave a Reply

Your email address will not be published. Required fields are marked *