9

I want to know, if possible, how to get a MAC address of an IP address if I am behind a router.

I tried doing a ping to the IP and checking the arp table, but the only entry is the router's MAC.

Any ideas?

Thanks for reading.

10 Answers 10

22

MAC addresses do not get passed on by routers. You need to look at the router's ARP table.

Edit:

Unless you have some other form of access to the machine, yes, it is impossible. If you can get onto the network it's on (VNC, RDP, SSH), then you can do it, but otherwise no.

If you're router doesn't give you the ARP table on its web interface, you could see if you can telnet in : many home routers have more advanced functions they hide from the web interface.

2
  • If I have no access to router's arp table, then it's impossible?
    – Macarse
    Jul 5, 2009 at 8:57
  • 1
    Yes. ARP is referred to as a non-routable protocol - it won't ever go outside of the local network. If you want to see MAC addresses, you have to be on a link-local device, either directly connected or with enough remote access to enumerate the ARP table. Jul 6, 2009 at 7:22
5

It cannot be guaranteed that you can see MAC address of machines behind a router. But there are some protocols that may help you in finding MAC address from anywhere in network. For example to find MAC address of a Windows PC on other network when you know its IP address you can use command

nbtstat -A <IP Address>

To do the same thing from Linux machine (with samba installed) use command

nmblookup -R -S -A <IP Address>

If the machine in question is not a windows machine and there is no way to become part of other subnet. Then the only options are seeing MAC address table in router, or if there is common network wide DHCP server then you can see MAC address in DHCP logs. But I guess you have to be administrator for accessing router or DHCP server.

Hence if there are lot of windows machines on your network you can find MAC address for them even when are not in their subnet. But if network has lot of Linux machines then there is no good very common way to find MAC from other networks.

The above technique wont work on Linux samba servers. They will always return MAC address as 00-00-00-00-00-00.

3

If the IP in question is not on a directly connected subnet of the router, then the MAC won't be in your router's ARP table.

ARP is only visible / relevant for the last hop of a IP connection (layer 2). Everything between the first routing entity and the last routing entity is layer 3, which doesn't use the ARP of the source or destination entities, but rather the ARP of the next directly-connected routing entity.

2

I think what you want to know is --

How can you find the MAC for a particular IP(machine) which is not the part of your subnet?

For the all the machines/IPs on your subnet the IP-MAC table is stored in ARP Cache, locally on your machine. This is the same cache which give "IP resolution conflicts". do a simple

$ arp -a | grep particularIP

Now for the machine outside your subnet -- there is no standard of the shelf application which does that, i tried to think if any ICMP message can do it, but as of now i think there is none. Well the way networking, rather layering is designed, this is a deliberately unwanted behavior. To escape or remove the information which is relevant to layers below the present, and as we across the networks IP is used, so no MAC.

See if you have cooperation at the other machine, you can write a small app, which encapsulates the the mac header and sends to you... ofcourse if u have cooperation from the other machine, why this much of effort a simple ifconfig -a does the job, that to for all the interfaces on that machine.

1

You can only "see" mac addresses of hosts that are on in the same subnet. Then, you can list all mac addresses using the arp command:

arp -a

or for a single IP address:

arp -a 192.168.0.1
1
  • I said that I am behind a router, so I am not in the same subnet.
    – Macarse
    Jul 5, 2009 at 14:54
0

If you have any access to the remote PC, or any PC on the remote network, you could use WMI or run various apps to give you the MAC address. I can't think of any other way you'd get the MAC address.

JR

1
  • No, I don't have any kind of access to the subnet :(
    – Macarse
    Jul 5, 2009 at 14:56
0

Do you know the device's manufacturer? If so, you may be able to get part of the MAC.

http://aruljohn.com/mac.pl

The only other thing I can think of is vxlan but I'm sure it would be more difficult to set that up than to just get access to the router which would have the MAC directly.

https://www.rfc-editor.org/rfc/rfc7348

0

Well as told by the folks in the other answer, ARP is a layer two protocol ans is not routable so scanning in conventional methods will not give you back MAC addresses. example

nmap -sn target

will only give MAC addresses of devices that are on the same network segment. There are two nmap scripts that use helpers such nbtstat and snmp

NBTSTAT this requires the UDP port 137 to be open on the target the nmap command is

nmap -sU --script nbtstat.nse -p 137 target

SNMP this protocol has to be functioning, it's port open, to give us any info about the MAC of the target. Also UDP port 161

nmap -sU -p 161 --script=snmp-interfaces target

IPV6 addresses this works on retrieving MAC from IPv6 or similar (teredo, 6to 4, etc) addresses. I've only tried it on IPv6 address that have part of the mac on them

nmap -sV -sC target

(this is the command from nmap https://nmap.org/nsedoc/scripts/address-info.html) but when testing it (on internal fe80 hosts), it required a -6 so

nmap -sV -sC -6 target 
-2

Try namp Intense Scan: nmap -T4 -A -v IP-address

1
  • 1
    Either you haven't understood the question, or you have no idea what you are talking about. I see no evidence suggesting that this command would ever see the MAC address on the other side of any router. Even if it did work, it wouldn't have been a good answer, because it is missing information about how it works.
    – kasperd
    Jan 2, 2016 at 12:39
-2

i don't know about router but if you have ip address you can use nmap to obtain mac address even in your local host you can do it as well so why the hell are you want obtain that from router or some thing like that ? if your os is linux you can use macchanger or lots of other apps so i have no idia why you want do this like that.

1
  • I think you missed the word router in the question.
    – kasperd
    Jan 11, 2016 at 9:14

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .