LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 06-12-2008, 03:47 AM   #1
Johnny Ljunggren
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Rep: Reputation: 0
Get MAC address of all NIC


Hello

I'm trying to find the MAC address of all NIC's on my machines, even those that do not show up using ifconfig -a.

Up till now I have resorted to dmesg and reading through the output or reading it off the NIC directly, but that is a bit cumbersome.

Is there a better way?

Johnny
 
Old 06-12-2008, 05:21 AM   #2
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682Reputation: 682
You could try filtering out the lines you need with:
Code:
dmesg | egrep '(^eth|^wlan|^ath).*([[:xdigit:]][[:xdigit:]]:){4}'
You will need to check if a wireless or pcmcia device shows up.
 
Old 06-12-2008, 05:30 AM   #3
Dudydoo
Member
 
Registered: Sep 2003
Location: UK
Distribution: I use 'em all ;-)
Posts: 275

Rep: Reputation: 38
Take a look at:
Code:
man 8 arp
 
Old 06-13-2008, 05:29 AM   #4
Johnny Ljunggren
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Thanks for your inputs

I thought about doing grep on the output but couldn't find a consistent way of doing it. For instance my dual lan NIC displays this:
e1000: eth2: e1000_probe: Intel(R) PRO/1000 Network Connection
ACPI: PCI Interrupt 0000:0b:02.1[B] -> GSI 23 (level, low) -> IRQ 23
e1000: 0000:0b:02.1: e1000_probe: (PCI:33MHz:32-bit) 00:04:23:d6:a7:e5
e1000: eth3: e1000_probe: Intel(R) PRO/1000 Network Connection

I'll never be sure if this will always work, so it's not a preferred option. Somehow the kernel knows about this, so it should be possible to extract it in a consistent manner. Maybe even a small c-program could do this?

When it comes to arp, AFAIK it only shows known hosts with known ip/mac addresses and not all interfaces on same machine.

Johnny
 
Old 06-13-2008, 05:31 AM   #5
billymayday
LQ Guru
 
Registered: Mar 2006
Location: Sydney, Australia
Distribution: Fedora, CentOS, OpenSuse, Slack, Gentoo, Debian, Arch, PCBSD
Posts: 6,678

Rep: Reputation: 122Reputation: 122
Fire up ethereal and ping the target NIC. That will give you the MAC
 
Old 06-13-2008, 07:23 AM   #6
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
How about:
ifconfig -a|grep HWaddr

<Edit>
OOPS, i missed your statement about "other than ifconfig -a"

If ifconfig -a doesn't find the NIC, does it not mean that no driver is installed?

Last edited by pixellany; 06-13-2008 at 02:18 PM. Reason: 2nd edit--fixed a typo
 
Old 06-16-2008, 04:19 AM   #7
Johnny Ljunggren
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Hmmm

It would seem correct that ifconfig -a should show all NIC's so I tried it some more and it seems to show all information I need. Don't really know what happened the first time but it seems that the solution was there all the time.

Anyway, thanks for all inputs!
 
Old 06-16-2008, 08:20 AM   #8
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
Just to toss one more option into the mix, even though you already have what you need..

lshw -C network

lshw is a great utility when it comes to querying any information about your hardware.
 
Old 06-17-2008, 04:05 AM   #9
Johnny Ljunggren
LQ Newbie
 
Registered: Apr 2008
Posts: 8

Original Poster
Rep: Reputation: 0
Excellent util!

It wasn't installed on the system, but I added it now. Didn't even know about it. Have been using lspci but that only gives an overview.

Thanks
 
Old 06-17-2008, 07:34 AM   #10
farslayer
LQ Guru
 
Registered: Oct 2005
Location: Northeast Ohio
Distribution: linuxdebian
Posts: 7,249
Blog Entries: 5

Rep: Reputation: 191Reputation: 191
glad you find it useful. lshw pulls information from several places on the system then formats it nicely. one of the main places it seems to pull from is another utility (which is usually installed by default) called dmidecode. so theres another command to add to your toolbox

enjoy !!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to change the MAC address of an NIC card. vishnu_sreekumar Linux - Networking 2 01-04-2007 07:24 AM
How to change the MAC address of an NIC card. vishnu_sreekumar Linux - Networking 2 01-03-2007 06:35 PM
modify nic mac-address mfran2002 Linux - Networking 4 10-19-2005 01:52 AM
changing nic mac address bishal Linux - Hardware 4 07-16-2004 04:44 PM
NIC gets different MAC address after each reboot?? BrianG Linux - Networking 1 04-09-2001 11:10 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 07:06 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration