Saturday, August 18, 2007 5:38 PMDoes anyone know how to get the MAC address of a computer?
The computer is in different subnet and connected through a router.
When I used the SendARP() function to get the MAC address, it worked when
running within the same subnet.
The problem is that SendARP() seems to return the MAC address of the router.
I tried both arp and nbtstat commands but they only worked when running
within the same subnet.
Does anyone know how this might work?
Saturday, August 18, 2007 5:51 PMModeratorUnfortunately MAC addresses really only have meaning on local networks... beyond that... anything can go... so to get the MAC address of the remote host... you’ll need some code running on the other side such as on the machine you are talking to (if you are building a client/server setup) that you can ask.
Monday, August 20, 2007 5:36 PMBrendan,
Thanks for your reply.
So far what you said is tru that I simply could not get the MAC address of a remote computer across routers.
However, I tried some SNMP browser (like Tembria) and it seemed to be able to get the correct MAC address.
Not sure how it does that, maybe by sniffing out the packets?
Monday, August 20, 2007 5:56 PMModerator
I cannot speak to how Tembria is able to get the remote mac address... I’d have to read up on the SNMP protocol and/or watch some wire traffic to see if it’s being passed back by the remote machine.
... however there’s nothing directly involved in TCP/IP that can give you the mac address of a remote machine... if you were to look at the network traffic at every step of the way, when your machine makes a request of a remote machine, your mac address exists only in the Data Link layer (from the OSI model) up until your message hits router, after that the two mac addresses involved are one of the router (so that the receiver knows where to send the message back to) and of the destination device/router... not the final machine mine you but the next one in the chain to reach it.
Monday, August 20, 2007 9:29 PM
Danny, here is a brief explanation of how it works with SNMP: http://geekswithblogs.net/Lance/archive/2007/08/20/How-to-Retrieve-Remote-MAC-Address-Programmatically.aspx.
Tuesday, August 28, 2007 10:46 PMLance,
Thanks for the help.
I was not sure about the following lines in your page:
snmpmgr1.ObjCount = 2;Not sure about settings two oid's.
snmpmgr1.ObjId = "126.96.36.199.188.8.131.52.1.3";
//ifEntryType, this is "6" for an ethernet adapter, "24" for loopback interface
//For a full list see rfc 1573
snmpmgr1.ObjId = "184.108.40.206.220.127.116.11.1.6"; //ifPhysAddress
However, I did find some sample code that seems to retrieve MAC address from
a remote device (going through my Netgear router).
Thank everyone for the help. All information has helped me understand this more.
Tuesday, August 04, 2009 11:54 AMI had the same problem, but was able to solve it by assigning a second local IP to my server with same subnet as the remote machines I want to obtain Mac address from: henceforth SendArp() returns Mac addresses of machines from both subnets!
- Proposed As Answer by scoket.joe Monday, August 31, 2009 9:42 AM
Monday, August 31, 2009 9:42 AMmanzztop,
can you tell me the method,how to assign a second local IP to self server with same subnet.
i had the same problem,i am sure your method can solve it.
Monday, May 31, 2010 4:32 AMTry to use GETMAC it help you out to get the MAC address of the Remote system ...
Monday, February 27, 2012 8:21 PMI need help in ... how do i change my computer's mac address ?
Monday, February 27, 2012 8:25 PMSomehow I think my computer is set to an ip self server and my computer's mac address has been compromised, can you tell me how i can get my computers mac address ?