如何从 HTTP 请求中获取 MAC 地址?
有人可以给我一些关于从 HTTP 请求中获取用户 MAC 地址的指示吗?
用户将来自我的网络外部。
Can someone give me some pointers on picking up the user's MAC address from an HTTP request?
The users will be from outside my network.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这取决于您的网络设置。但可能不会。
以下是对以太网和 IP 的简短回顾。 MAC地址是网卡的唯一地址。用于识别数据包属于该网段的哪个用户。您可以使用 ARP 来获取 IP 地址的 MAC 地址。 但只有当您位于同一网段时,这才会按预期工作。
那么问题来了,什么是网段呢?这取决于您使用的技术,但以下是常见情况。整个无线网络就是一个网段。网络上的每个用户都可以通过以太网与其他用户通信。在基于有线的网络上,这取决于硬件。如果您有旧的 BNC 或集线器,那么您就拥有了一个可用于所有用途的网段。同样,每个用户都可以与任何其他用户交谈。对于网络中的交换机,网段只是将您连接到交换机的电缆。在这里您只能通过以太网与交换机通信。每个其他用户至少需要 IP。
遗憾的是,大多数情况下,使用基于 TCP/IP 的 HTTP,您 99.99% 都不会与您的用户位于同一网段。您可以使用 ARP,但只能获取第一跳的 MAC 地址。更好的是,根据您的硬件,您甚至可能不在基于以太网的 IP 网络上;以ATM机为例...
It depends on your network setup. But probably no.
Here is a short refresher on Ethernet and IP. The MAC address is a unique address of the network card. It is used to identify for which user on the network segment a packet is. You can use ARP to get a MAC address for an IP address. But this works as expected only if you are on the same network segment.
So the question is, what is a network segment? It depends on the technology you use, but here are the common cases. An entire wireless network is a network segment. Every user on the network can talk via Ethernet to every other user. On wire based networks, this depends on the hardware. If you have good old BNC or a hub you have one network segment with all uses. Again each user can talk to any other. With a switch in the network a network segment is only cable that connects you to the switch. Here you can only talk to the switch via Ethernet. Every other user needs at least IP.
Too bad that most situations with HTTP, which builds on TCP/IP, you are 99.99% never in the same network segment as your user. You can use ARP, but will only get the MAC address of the first hop. It get's better, depending on your hardware, you may not even be on an IP network that is based on Ethernet; ATM for example...
我认为在 ASP.NET 中没有办法做到这一点。
MAC 是 TCP 数据包的一个属性,在 HTTP 级别上没有数据包或 MAC(例如,单个 HTTP 请求可能由多个 TCP 数据包组装而成)。
您可以尝试使用数据包嗅探器(如 WireShark)捕获 TCP 数据包,然后分析它们以提取 MAC 并将其映射到 HTTP 请求。
无论如何,除非用户与你的服务器处于同一网段,否则你不会获得任何有用的数据。
UPD。正如评论中指出的那样,我混淆了网络层。
MAC 地址是以太网帧的属性,而不是 TCP 数据包。
但结论仍然是正确的。
I don't think there is a way to do it in ASP.NET.
MAC is a property of a TCP packet, and on HTTP level there're no packets or MACs (for example, a single HTTP request might be assembled of several TCP packets).
You could try using a packet sniffer (like WireShark) to capture TCP packets, and then analyze them to extract MACs and map them to HTTP requests.
Anyway, you won't get any useful data unless the user is in the same network segment as your server.
UPD. As was pointed out in the comments, I mixed up the network layers.
MAC address is a property of Ethernet frame, not a TCP packet.
The conclusion is still correct, however.
这是不可能的,除非您打算创建 ActiveX 组件,在这种情况下它只能在 IE 上运行。
This is not possible, unless you intend to create an ActiveX component, in which case it will only work on IE.