1 |
On Fri, Apr 20, 2012 at 6:43 AM, Joost Roeleveld <joost@××××××××.org> wrote: |
2 |
> On Thursday, April 19, 2012 04:12:35 PM Michael Mol wrote: |
3 |
>> On Thu, Apr 19, 2012 at 4:01 PM, Alex Schuster <wonko@×××××××××.org> wrote: |
4 |
>> > Michael Mol writes: |
5 |
>> >> On Thu, Apr 19, 2012 at 3:40 PM, Alex Schuster <wonko@×××××××××.org> |
6 |
>> >> |
7 |
>> >> wrote: |
8 |
>> >> > New output: |
9 |
>> >> > eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 |
10 |
>> >> > inet 192.168.2.42 netmask 255.255.255.0 broadcast |
11 |
|
12 |
|
13 |
>> >> > 192.168.2.255 inet6 fe80::be5f:f4ff:fe19:ad18 prefixlen 64 scopeid |
14 |
>> >> > 0x20<link> |
15 |
|
16 |
|
17 |
>> >> > |
18 |
>> >> > ether bc:5f:f4:19:ad:18 txqueuelen 1000 (Ethernet) |
19 |
|
20 |
[snip] |
21 |
|
22 |
>> Incidentally, you can derive it from your IPv6 LL address, but that's |
23 |
>> a bit of a roundabout way, and may not work if you've disabled IPv6. |
24 |
> |
25 |
> How do you derive it? |
26 |
> I don't see the mac-address in the inet6 address. |
27 |
|
28 |
https://en.wikipedia.org/wiki/IPv6_address#Modified_EUI-64 |
29 |
|
30 |
The inet6 address listed is |
31 |
|
32 |
fe80::be5f:f4ff:fe19:ad18 |
33 |
|
34 |
and your MAC is |
35 |
|
36 |
bc:5f:f4:19:ad:18 |
37 |
|
38 |
First, let's chop off the fe80:: portion. The fe80 means it's a |
39 |
link-local address, and the :: means that that space in the address is |
40 |
greedily (think regex) filled with 0s. That leaves us with |
41 |
|
42 |
be5f:f4ff:fe19:ad18 |
43 |
|
44 |
Right in the middle of that, you see ff:fe. That part is added by |
45 |
IPv6's autoconfiguration logic. Yank that out, and you're left with |
46 |
|
47 |
be5f:f419:ad18 |
48 |
|
49 |
IPv6 addresses put the : between every group of 16 bits. The |
50 |
representation of your MAC address has the : between every group of 8 |
51 |
bits. So we just insert more : characters where they're missing. |
52 |
|
53 |
be:5f:f4:19:ad:18 |
54 |
|
55 |
Which is your MAC. |
56 |
|
57 |
This autoconfiguration logic is used all over the place as part of |
58 |
Stateless Link Automatic Address Configuration, or SLAAC, and it means |
59 |
you don't need DHCP for many environments. |
60 |
|
61 |
As an exercise example, here are the numbers on the latop I'm using right now: |
62 |
|
63 |
MAC: e0:69:95:c5:29:5f |
64 |
IPv6 link-local address: fe80::4eed:deff:fe93:63a0 |
65 |
IPv6 global address: 2001:470:c5b9:beef:4eed:deff:fe93:63a0 |
66 |
|
67 |
The breakdown of my global-scope address is slightly trickier, because |
68 |
there aren't a bunch of 0s for a :: to consume. My IPv6 ISP gave me a |
69 |
prefix of 2001:470:c5b9::/48, I set up my wireless network to have a |
70 |
prefix of 2001:470:c5b9:beef::/64. What's left, 4eed:deff:fe93:63ao, |
71 |
is common between the link-local and global-scope addresses. |
72 |
|
73 |
And you should now know enough to derive my MAC address from either my |
74 |
link-local address or my global-scope address. |
75 |
|
76 |
Note that this won't necessarily work on all platforms. If you have |
77 |
IPv6 privacy extensions enabled, a conforming IP stack (including on |
78 |
Linux) should still work this way...except Windows uses a *randomized |
79 |
MAC* as a basis. Also, if you're on a network which uses DHCPv6, I |
80 |
can't guarantee what you'd get for ULA or global-scope addresses |
81 |
(depends on your network admin's choices), but your link-local address |
82 |
should still look the same. |
83 |
|
84 |
-- |
85 |
:wq |