确定 Linux 上的 MAC 地址是物理地址还是虚拟地址

发布于 2024-10-30 11:38:12 字数 155 浏览 10 评论 0原文

我尝试过使用多个命令以及几个使用 C/C++ 的示例,但仍然无法找到可以区分物理或虚拟以太网适配器的完美方法。物理方式,在您的板上可用或外部安装,以及由虚拟化应用程序(例如 VirtualBox/VMWare/Virtual PC 或 VPN 等)创建的虚拟方式。

有什么指示吗?

I have tried using several commands as well as couple of examples using C/C++ but am still not able to find a flawless method that can differentiate between physical or virtual ethernet adapters. Physical means, on that available on your board or installed externally and virtual means created by virtualization apps such as VirtualBox/VMWare/Virtual PC or VPN etc.

Any pointers?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

季末如歌 2024-11-06 11:38:12

没有完美无缺的方法。虚拟适配器可以具有任何 MAC 地址,包括可能已由构造函数分配给物理设备的 MAC 地址。反之亦然,因为人们可以更改物理适配器的 MAC 地址。您只能做出有根据的猜测。

There is no flawless method. A virtual adapter can have any MAC address, including one that might have been assigned by a constructor to a physical device. And the other way around, given that one can change the MAC address of a physical adapter. You can only make an educated guess.

泛滥成性 2024-11-06 11:38:12

您可能会发现更容易检测自己是否正在运行虚拟化,而不是查找有关 NIC 的特定信息。 virt-what(1) 工具会检查正在运行的系统的各个方面,以猜测系统是否已虚拟化。 (该脚本并不像您想象的那么聪明,但它确实在一个地方有很多小型信息收集工具。)

故意试图绕过许可证检查的人可能不会发现很难击败这个机制。

You might find it easier to detect if you are running virtualized at all, rather than look for specific information about the NICs. The virt-what(1) tool looks through aspects of the running system to guess if the system is virtualized or not. (The script isn't as smart as you think, but it does have a lot of small information gathering tools in one place.)

Someone intentionally trying to bypass a license check would probably not find it difficult to defeat this mechanism.

单身狗的梦 2024-11-06 11:38:12

也许可以使用 mii-tool 并检查它是否失败,这适用于虚拟:

mii-tool vmbr2
SIOCGMIIPHY on 'vmbr2' failed: Operation not supported
mii-tool eno1
eno1: negotiated 1000baseT-FD flow-control, link ok

编辑:

什么是 mii-tool:查看、操作独立于媒体的接口状态

   This utility checks or sets the status of a network interface's
   Media Independent Interface (MII) unit.  Most fast ethernet
   adapters use an MII to autonegotiate link speed and duplex
   setting.

https://www.man7.org/linux/man-pages/man8/mii- tool.8.html

Maybe one can use mii-tool and check if it fails, which it does for virtual:

mii-tool vmbr2
SIOCGMIIPHY on 'vmbr2' failed: Operation not supported
mii-tool eno1
eno1: negotiated 1000baseT-FD flow-control, link ok

EDIT:

What is mii-tool: view, manipulate media-independent interface status

   This utility checks or sets the status of a network interface's
   Media Independent Interface (MII) unit.  Most fast ethernet
   adapters use an MII to autonegotiate link speed and duplex
   setting.

https://www.man7.org/linux/man-pages/man8/mii-tool.8.html

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文