从 Jetty HTTPServletRequest 获取 MAC 地址
有谁知道是否有办法从 Jetty 中的 HTTPServletRequest 获取发送者的 MAC 地址? (注意:发件人是指直接发件人,又称我的服务器之前的最后一跳)。如果没有直接的方法,有人知道在Java中将IP地址转换为MAC地址的方法吗?
其他注意事项:我完全意识到 MAC 地址不会离开本地子网,这就是预期的功能。
我知道这似乎是一个奇怪的问题,但相信我,我知道我在做什么:-) 如果您好奇,我很乐意解释为什么我想要这个。
谢谢,
克里斯
Does anybody know if there is a way to get the sender's MAC address from an HTTPServletRequest in Jetty? (Note: by sender, I mean immediate sender aka the last hop before my server). If there isn't a direct way, does anybody know a way to translate an IP address to a MAC address in Java?
Other note: I completely realize that MAC addresses do not leave the local subnet, and that's the intended functionality.
I know this seems like an odd question, but trust me, I know what I'm doing :-) If you're curious, I'd be happy to explain why I want this.
Thanks,
Chris
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
由于 MAC 地址未在 HTTP 请求中发送,因此您无法从 HttpServletRequest(在 Jetty 或任何应用程序服务器中)获取此地址。
您必须使用 ARP 自行查找地址。
Since the MAC address is not sent in the HTTP request, then no, you cannot get this from the HttpServletRequest (in Jetty or any app server).
You'd have to lookup the address yourself with ARP.
您还应该考虑您想要它的用途。它可以由用户更改,因此它首先不是识别客户的可靠方法。
You should also consider what you want it for. It can be altered by the user, so it isn't a reliable way of identifying clients in the first place.
不,你只有远程 IP,下面的网络层不存在。
正如马特回答的那样,您必须求助于一些 ARP 查找,但这并不是很简单,特别是在 Java 中。请参阅此相关问题。
No, you only have the remote IP, the network layers below are out of the picture.
You'd have to resort to some ARP lookup, as matt's answered, but that is not very straightforward, specially in Java. See this related question.