FAQ Search Today's Posts Mark Forums Read
» Video Reviews

» Linux Archive

Linux-archive is a website aiming to archive linux email lists and to make them easily accessible for linux users/developers.


» Sponsor

» Partners

» Sponsor

Go Back   Linux Archive > Gentoo > Gentoo User

 
 
LinkBack Thread Tools
 
Old 04-20-2012, 05:21 PM
Michael Mol
 
Default MAC from IPv6 address. WAS: How to find the MAC address

On Fri, Apr 20, 2012 at 6:43 AM, Joost Roeleveld <joost@antarean.org> wrote:
> On Thursday, April 19, 2012 04:12:35 PM Michael Mol wrote:
>> On Thu, Apr 19, 2012 at 4:01 PM, Alex Schuster <wonko@wonkology.org> wrote:
>> > Michael Mol writes:
>> >> On Thu, Apr 19, 2012 at 3:40 PM, Alex Schuster <wonko@wonkology.org>
>> >>
>> >> wrote:
>> >> > New output:
>> >> > eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> *mtu 1500
>> >> > * * * *inet 192.168.2.42 *netmask 255.255.255.0 *broadcast


>> >> > 192.168.2.255 inet6 fe80::be5f:f4ff:fe19:ad18 *prefixlen 64 *scopeid
>> >> > 0x20<link>


>> >> >
>> >> > * * * *ether bc:5f:f4:19:ad:18 *txqueuelen 1000 *(Ethernet)

[snip]

>> Incidentally, you can derive it from your IPv6 LL address, but that's
>> a bit of a roundabout way, and may not work if you've disabled IPv6.
>
> How do you derive it?
> I don't see the mac-address in the inet6 address.

https://en.wikipedia.org/wiki/IPv6_address#Modified_EUI-64

The inet6 address listed is

fe80::be5f:f4ff:fe19:ad18

and your MAC is

bc:5f:f4:19:ad:18

First, let's chop off the fe80:: portion. The fe80 means it's a
link-local address, and the :: means that that space in the address is
greedily (think regex) filled with 0s. That leaves us with

be5f:f4ff:fe19:ad18

Right in the middle of that, you see ff:fe. That part is added by
IPv6's autoconfiguration logic. Yank that out, and you're left with

be5f:f419:ad18

IPv6 addresses put the : between every group of 16 bits. The
representation of your MAC address has the : between every group of 8
bits. So we just insert more : characters where they're missing.

be:5f:f4:19:ad:18

Which is your MAC.

This autoconfiguration logic is used all over the place as part of
Stateless Link Automatic Address Configuration, or SLAAC, and it means
you don't need DHCP for many environments.

As an exercise example, here are the numbers on the latop I'm using right now:

MAC: e0:69:95:c5:29:5f
IPv6 link-local address: fe80::4eed:deff:fe93:63a0
IPv6 global address: 2001:470:c5b9:beef:4eed:deff:fe93:63a0

The breakdown of my global-scope address is slightly trickier, because
there aren't a bunch of 0s for a :: to consume. My IPv6 ISP gave me a
prefix of 2001:470:c5b9::/48, I set up my wireless network to have a
prefix of 2001:470:c5b9:beef::/64. What's left, 4eed:deff:fe93:63ao,
is common between the link-local and global-scope addresses.

And you should now know enough to derive my MAC address from either my
link-local address or my global-scope address.

Note that this won't necessarily work on all platforms. If you have
IPv6 privacy extensions enabled, a conforming IP stack (including on
Linux) should still work this way...except Windows uses a *randomized
MAC* as a basis. Also, if you're on a network which uses DHCPv6, I
can't guarantee what you'd get for ULA or global-scope addresses
(depends on your network admin's choices), but your link-local address
should still look the same.

--
:wq
 
Old 04-21-2012, 03:16 PM
Stroller
 
Default MAC from IPv6 address. WAS: How to find the MAC address

On 20 April 2012, at 18:21, Michael Mol wrote:
> …
> The inet6 address listed is
>
> fe80::be5f:f4ff:fe19:ad18
>
> and your MAC is
>
> bc:5f:f4:19:ad:18
>
> …
>
> be:5f:f4:19:ad:18
>
> Which is your MAC.

And then we just convert all incidences of the letter "e" to "c"? Is there some rule for this part?

Perhaps I'm missing something here.

Stroller.
 
Old 04-21-2012, 03:58 PM
Michael Mol
 
Default MAC from IPv6 address. WAS: How to find the MAC address

On Sat, Apr 21, 2012 at 11:16 AM, Stroller
<stroller@stellar.eclipse.co.uk> wrote:
>
> On 20 April 2012, at 18:21, Michael Mol wrote:
>> …
>> The inet6 address listed is
>>
>> *fe80::be5f:f4ff:fe19:ad18
>>
>> and your MAC is
>>
>> *bc:5f:f4:19:ad:18
>>
>> …
>>
>> *be:5f:f4:19:ad:18
>>
>> Which is your MAC.
>
> And then we just convert all incidences of the letter "e" to "c"? Is there some rule for this part?
>
> Perhaps I'm missing something here.

Whups. Missed a spot. Thank you for so graciously pointing it out.

So, on this laptop, here's the output of

ip -6 addr show wlan0

6: wlan0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP qlen 1000
link/ether 4c:ed:de:93:63:a0 brd ff:ff:ff:ff:ff:ff
inet 192.168.83.146/27 brd 192.168.83.159 scope global wlan0
inet6 2001:470:c5b9:beef:4eed:deff:fe93:63a0/64 scope global dynamic
valid_lft 86100sec preferred_lft 14100sec
inet6 fe80::4eed:deff:fe93:63a0/64 scope link
valid_lft forever preferred_lft forever

So you can see my MAC is

4c:ed:de:93:63:a0

and that I have a couple IPv6 addresses:

fe80::4eed:deff:fe93:63a0
2001:470:c5b9:beef:4eed:deff:fe93:63a0

(They look like they have different lengths, but that's because the
bits between fe80 and 4eed in the first one are all 0s, and so are
collapsed by using :

Take only the host portion of those addresses, and you get:

4eed:deff:fe93:63a0

Remove the ff:fe from the middle, and redistribute the : delimiters to
be every byte.

43:ed:de::93:63:a0

Compare with my MAC:
4c:ed:de:93:63:a0

And, yeah, that second digit is different again. That's because bit 7
is inverted. From RFC4291:

Modified EUI-64 format interface identifiers are formed by inverting
the "u" bit (universal/local bit in IEEE EUI-64 terminology) when
forming the interface identifier from IEEE EUI-64 identifiers. In
the resulting Modified EUI-64 format, the "u" bit is set to one (1)
to indicate universal scope, and it is set to zero (0) to indicate
local scope. The first three octets in binary of an IEEE EUI-64
identifier are as follows:

0 0 0 1 1 2
|0 7 8 5 6 3|
+----+----+----+----+----+----+
|cccc|ccug|cccc|cccc|cccc|cccc|
+----+----+----+----+----+----+

written in Internet standard bit-order, where "u" is the
universal/local bit, "g" is the individual/group bit, and "c" is the
bits of the company_id. Appendix A, "Creating Modified EUI-64 Format
Interface Identifiers", provides examples on the creation of Modified
EUI-64 format-based interface identifiers.

--
:wq
 
Old 04-21-2012, 05:00 PM
Grant Edwards
 
Default MAC from IPv6 address. WAS: How to find the MAC address

On 2012-04-21, Stroller <stroller@stellar.eclipse.co.uk> wrote:
>
> On 20 April 2012, at 18:21, Michael Mol wrote:
>> ?
>> The inet6 address listed is
>>
>> fe80::be5f:f4ff:fe19:ad18
>>
>> and your MAC is
>>
>> bc:5f:f4:19:ad:18
>>
>> ?
>>
>> be:5f:f4:19:ad:18
>>
>> Which is your MAC.
>
> And then we just convert all incidences of the letter "e" to "c"? Is
> there some rule for this part?

Yes. I answered that question in the original thread. You toggle bit
1 of the first byte of the MAC address when converting to/from an IPv6
LL address.

> Perhaps I'm missing something here.

RFC2464 sections 4 and 5.

--
Grant Edwards grant.b.edwards Yow! I just had my entire
at INTESTINAL TRACT coated
gmail.com with TEFLON!
 

Thread Tools




All times are GMT. The time now is 06:09 AM.

VBulletin, Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright 2007 - 2008, www.linux-archive.org