Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to get a client's MAC address from HttpServlet?

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)

like image 758
Amir Arad Avatar asked May 08 '09 14:05

Amir Arad


People also ask

How do I find clients MAC address?

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.

Can I get MAC address from http request?

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.

Can we get MAC address from JavaScript?

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.

How are MAC addresses obtained?

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.

How to get client IP address in a servlet?

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...

Is it possible to get the MAC address of a server?

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.

How to read HTTP header in servlet program?

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

What is httpservletrequestgetremotehost in servlet?

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:


2 Answers

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.

alt text

Encapsulation

like image 113
atom255 Avatar answered Sep 21 '22 06:09

atom255


TCP/IP... You can't get the MAC Address, that's a too low layer AFAIK

like image 31
ivmos Avatar answered Sep 18 '22 06:09

ivmos