How am I supposed to find the MAC address of an ethernet interface? I used
to call ifconfig and grep for HWaddr, but this does not work any more.
I found the 'old-output' USE flag for sys-apps/net-tools, which brings
back the old behaviour in order not to break old scripts, but I'd like to
know what the new method is that scripts should use.
On Thu, Apr 19, 2012 at 3:40 PM, Alex Schuster <wonko@wonkology.org> wrote:
> Hi there!
>
> How am I supposed to find the MAC address of an ethernet interface? I used
> to call ifconfig and grep for HWaddr, but this does not work any more.
>
> I found the 'old-output' USE flag for sys-apps/net-tools, which brings
> back the old behaviour in order not to break old scripts, but I'd like to
> know what the new method is that scripts should use.
>
> Here's how the output looked before and now:
>
> Old output:
> eth0 * * *Link encap:Ethernet *HWaddr bc:5f:f4:19:ad:18
> * * * * *inet addr:192.168.2.42 *Bcast:192.168.2.255 *Mask:255.255.255.0
> * * * * *inet6 addr: fe80::be5f:f4ff:fe19:ad18/64 Scope:Link
> * * * * *UP BROADCAST RUNNING MULTICAST *MTU:1500 *Metric:1
> * * * * *RX packets:11027476 errors:0 dropped:0 overruns:0 frame:0
> * * * * *TX packets:8002728 errors:0 dropped:0 overruns:0 carrier:1
> * * * * *collisions:0 txqueuelen:1000
> * * * * *RX bytes:11763889583 (10.9 GiB) *TX bytes:1006570663 (959.9 MiB)
> * * * * *Interrupt:49
>
> 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>
On 04/19/12 15:40, Alex Schuster wrote:
> Hi there!
>
> How am I supposed to find the MAC address of an ethernet interface? I used
> to call ifconfig and grep for HWaddr, but this does not work any more.
>
> I found the 'old-output' USE flag for sys-apps/net-tools, which brings
> back the old behaviour in order not to break old scripts, but I'd like to
> know what the new method is that scripts should use.
`ip link`
Learning a new command for something so fundamental was annoying, but
now I'm much happier.
04-19-2012, 07:50 PM
Neil Bothwick
How to find the MAC address
On Thu, 19 Apr 2012 21:40:02 +0200, Alex Schuster wrote:
> How am I supposed to find the MAC address of an ethernet interface? I
> used to call ifconfig and grep for HWaddr, but this does not work any
> more.
> Here's how the output looked before and now:
>
> Old output:
> eth0 Link encap:Ethernet HWaddr bc:5f:f4:19:ad:18
~~~~~~~~~~~~~~~~~
> New output:
> eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST mtu 1500
> ether bc:5f:f4:19:ad:18 txqueuelen 1000 (Ethernet)
~~~~~~~~~~~~~~~~~
here?
--
Neil Bothwick
"I need your clothes, your boots, and your tagline!"
04-19-2012, 07:56 PM
Michael Mol
How to find the MAC address
On Thu, Apr 19, 2012 at 3:48 PM, Michael Orlitzky <michael@orlitzky.com> wrote:
> On 04/19/12 15:40, Alex Schuster wrote:
>> Hi there!
>>
>> How am I supposed to find the MAC address of an ethernet interface? I used
>> to call ifconfig and grep for HWaddr, but this does not work any more.
>>
>> I found the 'old-output' USE flag for sys-apps/net-tools, which brings
>> back the old behaviour in order not to break old scripts, but I'd like to
>> know what the new method is that scripts should use.
>
> `ip link`
>
> Learning a new command for something so fundamental was annoying, but
> now I'm much happier.
>
I'll second this. The 'ip' command is far and away a nicer tool than
ifconfig, once you get a handle on it.
--
:wq
04-19-2012, 08:01 PM
Alex Schuster
How to find the MAC address
Michael Mol writes:
> On Thu, Apr 19, 2012 at 3:40 PM, Alex Schuster <wonko@wonkology.org>
> wrote:
Wow. Now I feel really stupid. Because I am. I have no idea why I have
overlooked this.
Sorry for the noise!
Wonko
04-19-2012, 08:12 PM
Michael Mol
How to find the MAC address
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)
>>
>> There it is.
>
> Wow. Now I feel really stupid. Because I am. I have no idea why I have
> overlooked this.
>
> Sorry for the noise!
I didn't see it right away, either. I found it by noticing your MAC in
your old output, and searched for a substring of it in your new
output.
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.
--
:wq
04-19-2012, 08:14 PM
Alex Schuster
How to find the MAC address
Neil Bothwick writes:
> On Thu, 19 Apr 2012 21:40:02 +0200, Alex Schuster wrote:
> On 04/19/12 15:40, Alex Schuster wrote:
> > Hi there!
> >
> > How am I supposed to find the MAC address of an ethernet interface? I
> > used to call ifconfig and grep for HWaddr, but this does not work any
> > more.
> >
> > I found the 'old-output' USE flag for sys-apps/net-tools, which brings
> > back the old behaviour in order not to break old scripts, but I'd
> > like to know what the new method is that scripts should use.
>
> `ip link`
>
> Learning a new command for something so fundamental was annoying, but
> now I'm much happier.
Thanks, that's a nice one. But can I expect this command to be available
per default on typical Linux distributions? Some other systems I have
access to have it, but here on Gentoo it belongs to sys-apps/iproute2,
which depends on nothing I have installed, I do not even know why I
emerged it in the first place. So maybe I better use ifconfig which is
always available, although sometimes in /bin and sometimes in /sbin, and
I have to check the output to see which version it is.
Wonko
04-19-2012, 09:04 PM
Michael Orlitzky
How to find the MAC address
On 04/19/12 16:40, Alex Schuster wrote:
>
> Thanks, that's a nice one. But can I expect this command to be available
> per default on typical Linux distributions? Some other systems I have
> access to have it, but here on Gentoo it belongs to sys-apps/iproute2,
> which depends on nothing I have installed, I do not even know why I
> emerged it in the first place. So maybe I better use ifconfig which is
> always available, although sometimes in /bin and sometimes in /sbin, and
> I have to check the output to see which version it is.
>
Gentoo prefers it over net-tools, and a few of the conf files mention
that, which explains how it could have wound up installed.
(Google says) iproute2 was introduced to replace net-tools around the
time of kernel-2.2, and (I says) they're needed to do anything remotely
complicated with the networking stack. So, they're probably pretty
standard these days.