0

Is there a way to get a remote (next hop) mac address with only knowing local interface name through with I will be sending traffic?

What I mean is: I have two computers interconnected, each have e.g. 4 network interfaces 2 of them are connected (one computer to another), now I know that on the first computer I will use eth0 and I assign an IP to it. Now I would like to get the mac address of the other end (network interface on second computer), is there a way to do this?

My idea is to just send something on the wire and get the other end to response with mac address. Is it possible somehow?

Explanation:

  1. I have two computers connected by a wire

  2. Those computers are running linux, there is no network manager, network interfaces are managed statically

  3. On computer A I configure an interface ethA to have an IP and take it up (ifconfig ethA IP up)

  4. On computer B i dont configure anything, but i take up every interface

  5. Now the question: I want to detect from computer A to which interface on computer B is network interface ethA (on computer A) connected and get its mac address. Meaning the wire connects two interfaces so the only think I need is to just use that wire and send something to it which will get me the remote interface MAC.

To explain why I need this:

We have a lot of servers and those server has a lot of interfaces (4 - 10) and one interface is used for ssh to those servers and the others interfaces are for connecting one server to another so there are 2,3,4 lines between a pair of servers and because we need to automate our tests we need to know which interface is connected to which - we actually need the interface name, not mac, because the name is one of parameters to our application which we develop.

Thanks

2
  • What exactly do you mean? Are you assuming you do not have an IP address? Or you just want to find out its MAC address, after having set up a connection between the two? Commented Jan 14, 2016 at 13:19
  • Edited question, added explanation
    – Jan
    Commented Jan 14, 2016 at 13:45

2 Answers 2

0

If your hosts are communicating each other, rempote host's mac should be presented in your local arp table. Just check it with arp -i *interface name* -a command. If not, you may look towards arping or similar soft

2
  • Thanks, the first did not work, with arping you have to know the dest IP which I don't, the interface don't even have IP assigned to it. The only think that I need is to send something that will response in the remote mac with only knowing the local interface (name, IP, mac )
    – Jan
    Commented Jan 14, 2016 at 10:57
  • From here looks like arp-scan should help you. Commented Jan 14, 2016 at 11:04
0

So you want to know the MAC address of a remote interface before a connection is established.

Do your pc-Bs run network-manager? if so, the simplest thing is to run dhcpdump (needs to be installed from the repos), by means of

  sudo dhcpdump - i eth0

where eth0 is the interface on pc-A with the cable. When you plug the other end of the cable into one of the interfaces of pc-B, if Network-manager is running on pc-B, it will try to get itself an IP address; in doing so, it will trigger dhcpdump, which will show a DHCP/BOOTP request from pc-B, including its MAC address.

Just leave dhcpdump on as you plug and unplug the cable in the various ethernet slots.

1
  • Thanks, this would be easy with network manager, but I don't have network manager enabled
    – Jan
    Commented Jan 18, 2016 at 17:44

You must log in to answer this question.

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