如何从 HttpServlet 获取客户端的 MAC 地址? [英] how to get a client's MAC address from HttpServlet?

查看:30
本文介绍了如何从 HttpServlet 获取客户端的 MAC 地址?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我被要求编写一个 servlet 来收集客户端的详细信息,例如 ip、ma​​c 地址等.

获取他的 IP 非常简单(request.getRemoteAddr()),但我没有找到一种优雅的方法来获取他的 MAC 地址.

Web 服务器可以访问诸如 Mac 地址等数据似乎是合理的,因为它获取了 TCP 数据包和所有内容.该数据是否在某处注册?可以访问吗?

(我在 Tomcat6 之上工作)

解决方案

你可能不会得到你想要的.(客户端的MAC地址)

如果服务器足够近(通过集线器或交换机直接连接),您可以

I was asked to write a servlet that collects client's details such as ip, mac address etc.

getting his IP is pretty straight-forward (request.getRemoteAddr()) but I dont find an elegant way to get his MAC address.

seems reasonable that the web server has access to data such as Mac address etc, since it gets the TCP packets and all. does this data registers somewhere? is it accessible?

(I'm working on top of Tomcat6)

解决方案

You're probably not going to get what you want. (the client's MAC address)

If the server is close enough (directly connected via hub or maybe a switch) you can ARP for the MAC Address. If you do this for an IP across the Internet you're probably going to get the inside interface of the closest Router or Switch.

Because of the way TCP/IP works the MAC address used in the 'frame' will get ripped off and re-assembled each at each hop the information takes between the server and the host.

Encapsulation

这篇关于如何从 HttpServlet 获取客户端的 MAC 地址?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆