mathzhaoliang
V2EX  ›  问与答

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

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

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

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

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