On Thu, Apr 19, 2012 at 10:40 PM, Alex Schuster <wo...@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> > ether bc:5f:f4:19:ad:18 txqueuelen 1000 (Ethernet) > RX packets 10791981 bytes 11413935608 (10.6 GiB) > RX errors 0 dropped 0 overruns 0 frame 0 > TX packets 7867427 bytes 996505563 (950.3 MiB) > TX errors 0 dropped 0 overruns 0 carrier 1 collisions 0 > device interrupt 49 > > Wonko > > You can grab mac of eth0 with this command: ip link show eth0 | grep 'link/ether' | awk '{print $2}' Kfir