Computing.Net > Forums > Unix > get ethernet NIC'c MAC address

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

get ethernet NIC'c MAC address

Reply to Message Icon

Name: WANG Yong
Date: October 24, 2002 at 00:31:08 Pacific
OS: SCO OSR 5.0.5
CPU/Ram: Intel PII/128
Comment:

Can anybody tell me how i can get the ethernet adpater's MAC address using C API. My OS is SCO openserver 5.0.5. Please attach your code sample. Thank you.



Sponsored Link
Ads by Google

Response Number 1
Name: David Perry
Date: October 24, 2002 at 09:35:55 Pacific
Reply:

I don't have a sco machine to test this against. Apologies for this not being a C answer. Flavor to suit.

On my linux machine, ifconfig -a produces this output

ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:50:04:16:65:04
BROADCAST MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
Interrupt:5 Base address:0x9c00

I can get the mac address:

MAC=`ifconfig -a | \
grep 'HWaddr' | \
head -1 | \
awk '{ print $5 }'`
echo $MAC


0

Response Number 2
Name: WANG Yonf
Date: October 24, 2002 at 20:46:44 Pacific
Reply:

thank u, I know on SCO i can use "ndstat" to get MAC address, but i need C API to do it, how can i do?


0

Response Number 3
Name: the gleek
Date: November 7, 2002 at 11:38:21 Pacific
Reply:


actually, you can do that same thing without the head and grep command since awk has that built right into it, as such:

echo `ifconfig -a | awk /ether/'{ print $2 }'`

gives you the same results, but on some *nix machines it shows "ether" before the mac address rather then "HWaddr".

but i'm still wondering how one would get a MAC address of an IP OUTSIDE a network to track customers for billing purposes (ISP-related)


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


video card for freebsd du... awk



Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Unix Forum Home


Sponsored links

Ads by Google


Results for: get ethernet NIC'c MAC address

get mac address www.computing.net/answers/unix/get-mac-address/4622.html

How to read Mac address of NIC www.computing.net/answers/unix/how-to-read-mac-address-of-nic-/4619.html

How to test ethernet Card with MAC addr www.computing.net/answers/unix/how-to-test-ethernet-card-with-mac-addr/3087.html