mathzhaoliang
V2EX  ›  问与答

在 Linux 下怎样用 C 语言仅使用标准/系统库函数,获取物理 mac 地址

  •  
  •   mathzhaoliang · Mar 7, 2019 · 1874 views
    This topic created in 2798 days ago, the information mentioned may be changed or developed.

    我的问题是这样的:我需要在 ubuntu 上写一个 C 函数,获取当前机器的物理 mac 地址,要求只能用 linux 系统的库函数和标准 C 库函数。我遇到的难点是一台机器上可能有多个网卡,所以 ifconfig 会返回多个网卡的 mac 地址。而且用户可能自己修改虚拟的网卡地址。怎么才能准确地找出机器唯一的物理 mac 地址呢?

    注:不要使用 lshw 这个工具。

    LGA1150
    LGA1150
    Mar 7, 2019 via Android
    1
    getifaddrs
    ysc3839
    ysc3839
    Mar 7, 2019
    2
    看 ifconfig 的代码。
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2872 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 13:17 · PVG 21:17 · LAX 05:17 · JFK 08:17
    ♥ Do have faith in what you're doing.