Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6864085
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T02:52:03+00:00 2026-05-27T02:52:03+00:00

I am trying to find out MAC address and I managed to create working

  • 0

I am trying to find out MAC address and I managed to create working solution using sysctl in Linux, problem is, that this solution is not working on FreeBSD version I am developing on. Is there any way I can find out mac address in C other than using sysctl?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T02:52:03+00:00Added an answer on May 27, 2026 at 2:52 am

    Use the libpcap library. Its the most multi platform way you can find.

    This library is used on network sniffers and intrusion detections, as well as dedicate measuring other network statistics. The nethogs utility to measure per process network usage, the iftop used to measure per machine/port bandwidth usage. Is very flexible in many roles.

    Is written in C but there are some wrappers for other languages.

    1: http://en.wikipedia.org/wiki/Pcap
    [2]: http://www.tcpdump.org
    [3]: http://sourceforge.net/projects/libpcap/

    Edit:
    here is a complete and exact and working example with the code and functions detailed:
    http://coderrr.wordpress.com/2008/03/07/get-the-mac-address-of-a-local-ip/

    There are plenty of tutorials and the source code is your best friend.

    Edit 2: blaze pointed out getifaddrs(3) which seems to do the job, just a few caveats, its a non-posix function. Is a bsd function which glibc linux supports but do NOT documents. Is almost an undocumented featured 🙂

    All documentation are man pages and from the manual at kernel.org:

    Not in POSIX.1-2001. This function first appeared in BSDi and is
    present on
    the BSD systems, but with slightly different semantics documented–returning
    one entry per interface, not per address. This means ifa_addr and other
    fields can actually be NULL if the interface has no address, and no link-level
    address is returned if the interface has an IP address assigned. Also, the
    way of choosing either ifa_broadaddr or ifa_dstaddr differs on various
    systems.

    and

    The addresses returned on Linux will usually be the IPv4 and IPv6
    addresses
    assigned to the interface, but also one AF_PACKET address per interface
    containing lower-level details about the interface and its physical layer. In
    this case, the ifa_data field may contain a pointer to a struct
    net_device_stats, defined in , which contains various
    interface attributes and statistics.

    So it may vary in behavior and you’ll may have to #ifndef compile anyway.

    The kernel.org man page at http://www.kernel.org/doc/man-pages/online/pages/man3/getifaddrs.3.html does provides example code in it, which may be helpful. My local linux man page is rather poor in comparison to the above linked.

    I still think that libpcap is more portable if only because someone else had done all the portability work and all the extra features you gain by using it.

    Hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Im trying to find out a good JavaScript library that can create a nice
I am trying to find out mac address of a machine in a switched
I'm trying to find out whether I should be using business critical logic in
I'm trying to find out if my install scrip is running on a Mac
I'm trying to find out how much memory my own .Net server process is
I'm trying to find out if there is any way to elevate a specific
I'm trying to find out the 'correct' windows API for finding out the localized
I am trying to find out how to upload a file from a web
I am trying to find out how much memory my application is consuming from
I'm trying to find out the most efficient (best performance) way to check date

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.