LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-03-2011, 05:33 AM   #1
danndp
Member
 
Registered: Nov 2010
Posts: 51

Rep: Reputation: 2
obtaining the MAC of the interfaces


Hi,

I'm running this command, and seems not to work, following the command:

Quote:
for nic in `ls /sys/class/net | grep -v lo`; do echo ${nic}; udevinfo -a -p /class/net/{nic} | grep -i address; done
The output is the following:

Quote:
eth0
eth1
But the output should show something like this: (showing the MAC address)

Quote:
eth0
SYSFS{address}=="00:26:55:df:5d:ba"
eth1
SYSFS{address}=="00:26:55:df:5d:b9"
Am i missing something with the command?

Regards!
 
Old 06-03-2011, 05:39 AM   #2
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Yo!

Quote:
Am i missing something with the command?
yes...you're using the wrong command IMHO...

Use

Quote:
arp -a
to see the MAC of the nic's in the box...

Wellness

Thor
 
Old 06-03-2011, 05:44 AM   #3
blue_print
Member
 
Registered: May 2010
Location: In world
Distribution: RHEL, CentOS, Ubuntu
Posts: 275
Blog Entries: 3

Rep: Reputation: 50
Looks like, the for loop is not correct. Please use the following one, it will work.
Code:
for nic in `ls /sys/class/net | grep -v lo`; do echo ${nic}; udevinfo -a -p /sys/class/net/${nic}/address | grep -i address | grep -v looking | grep -v KERNEL; done
 
1 members found this post helpful.
Old 06-03-2011, 05:46 AM   #4
danndp
Member
 
Registered: Nov 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Quote:
yes...you're using the wrong command IMHO...
Well, i found the mistake =) the command should be like this:

Quote:
for nic in `ls /sys/class/net | grep -v lo`; do echo ${nic}; udevinfo -a -p /class/net/${nic} | grep -i address; done
As you can see, i missed a $ =)

Many thanks for your help

Regards!
 
1 members found this post helpful.
Old 06-03-2011, 05:47 AM   #5
danndp
Member
 
Registered: Nov 2010
Posts: 51

Original Poster
Rep: Reputation: 2
Quote:
Originally Posted by blue_print View Post
Looks like, the for loop is not correct. Please use the following one, it will work.
Code:
for nic in `ls /sys/class/net | grep -v lo`; do echo ${nic}; udevinfo -a -p /sys/class/net/${nic}/address | grep -i address | grep -v looking | grep -v KERNEL; done
THANKS blue print =)
 
Old 06-03-2011, 05:48 AM   #6
ButterflyMelissa
Senior Member
 
Registered: Nov 2007
Location: Somewhere on my hard drive...
Distribution: Manjaro
Posts: 2,686
Blog Entries: 23

Rep: Reputation: 398Reputation: 398Reputation: 398Reputation: 398
Thanks!

I learned something here

THor
 
Old 06-03-2011, 05:54 AM   #7
jschiwal
LQ Guru
 
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670Reputation: 670
You could get the MAC address from the contents of the /sys/class/net/*/address file.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
got two interfaces with same mac goncalopp Linux - Networking 4 05-07-2011 10:46 AM
obtaining ip address from mac address Mastupristi Linux - Wireless Networking 8 10-12-2010 06:47 PM
How to find *hardware* mac addresses on bonded interfaces? TotalDefiance Linux - Software 3 06-06-2006 12:53 PM
mac osx problems with linux samba after switching network interfaces cruiserparts Linux - Networking 2 01-22-2006 08:41 PM
obtaining debian dvd iso with mac os x bobotoes Linux - Newbie 4 09-30-2004 10:56 PM


All times are GMT -5. The time now is 07:57 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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration