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)
To find the MAC ID / Address of a system, either: Locate the MAC ID label on the back plastics of the system. On integrated thin clients, the MAC ID label is located on the back, below the power input jack. On thin client computers, the MAC ID label is located on the back of the system, below the certification label.
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.
No you cannot get the MAC address in JavaScript, mainly because the MAC address uniquely identifies the running computer so it would be a security vulnerability.
A MAC address is given to a network adapter when it is manufactured. It is hardwired or hard-coded onto your computer's network interface card (NIC) and is unique to it. Something called the ARP (Address Resolution Protocol) translates an IP address into a MAC address.
Methods to get client IP address in a servlet. There are mainly two methods used to get the remote address or client address. They are as follows: HttpServletRequest.getRemoteAddr(): This method returns the internet address of the client sending the request. HttpServletRequestgetRemoteHost(): This returns the host name...
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.
This header identifies the browser or other client making the request and can be used to return different content to different types of browsers. There are following methods which can be used to read HTTP header in your servlet program. These methods are available with HttpServletRequest object
HttpServletRequestgetRemoteHost (): This returns the host name of the client sending the request. If the name is unknown then its returns an empty string. Example of getting clients address in a servlet:
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
TCP/IP... You can't get the MAC Address, that's a too low layer AFAIK
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With