| Thread Closed |
Read MAC address in Linux |
Share Thread | Thread Tools |
| Dec15-06, 02:07 PM | #1 |
|
|
Read MAC address in Linux
Hello,
Is there a way to read the MAC address of a linux system directly? ie not from the output of arp or ifconfig ---> Where does ifconfig read the MAC address from? Thanks |
| PhysOrg.com |
science news on PhysOrg.com >> Hong Kong launches first electric taxis >> Morocco to harness the wind in energy hunt >> Galaxy's Ring of Fire |
| Dec15-06, 02:25 PM | #2 |
|
|
It reads it from the kernel. You can probably find it somewhere in the /proc filesystem.. I'll browse around.
- Warren |
| Dec15-06, 03:04 PM | #3 |
|
|
Parsing the output, as you suggested, is one way. Looking at a socket object is another. I think this would probably be the best way to do it under Linux.
Here's an example of how one might do this in Python: Code:
import socket
sock = socket.socket (socket.AF_PACKET,socket.SOCK_RAW)
sock.bind (("eth0", 9999))
mac = s.getsockname()[-1]
|
| Dec15-06, 03:37 PM | #4 |
|
|
Read MAC address in Linux
I actually just found this example which works.
Thanks for the help chroot and Sane. http://english.geekpage.jp/programmi...et-macaddr.php |
| Dec15-06, 03:52 PM | #5 |
|
|
Haha, yes. That's exactly what I had suggested.
It looks at a socket object to see the MAC address. |
| Thread Closed |
| Thread Tools | |
Similar Threads for: Read MAC address in Linux
|
||||
| Thread | Forum | Replies | ||
| IP address | Computers | 4 | ||
| Windows Vista, Linux 32-bit, Linux 64-bit | Computing & Technology | 1 | ||
| Why was my IP address banned? | Forum Feedback & Announcements | 3 | ||
| Which Kurt Vonnegut books to read next? Or should I read Catch 22 instead? | General Discussion | 10 | ||