11

Given a Linux server with an ethernet card, another device say an unconfigured router is connected with a patch lead (or an ethernet lead cabled in a different way if needed).

They're both powered up. Is there a way on the linux box to get the MAC address of the other device? There's no IP network going on here just two connected ethernet interfaces.

EDIT: The devices that this is concerning come with base config expecting to get an IP off a DHCP server which I can run on the linux host and work off that as soon as they get their temp IP.

9
  • I think you have no chance to know peer's ethernet address unless the peer spontaneously sends something / responds to something you sent in some protocol like STP, ARP (IPv4), NDP (IPv6). Can't you assume anything on that?
    – yaegashi
    Sep 10, 2015 at 10:52
  • Well the router will broadcast a request looking for a DHCP server by default but I'm more on the programmer side of things I'm not sure how that works, L2 broadcast isnt it?
    – Recct
    Sep 10, 2015 at 11:00
  • Not an answer to question, as it stands, but those who aim at IP connection over a direct Ethernet patch link may use ifconfig iface pointopoint IP.address.of.another.point That will make ARP unnecessary. See ifconfig(8) for details. Sep 10, 2015 at 12:24
  • 1
    You might want to try setting any IP address on the Linux system's Ethernet interface and then run ping -b 255.255.255.255 and then arp -a -n. There's no universal way to remotely discern an unconfigured router port's MAC because some routers do not enable ports until they're configured to do so. Sep 10, 2015 at 15:29
  • 1
    Many routers use LLDP for discovery. You may use command tshark -i <imterface> -Y lldp to capture LLDP packets, which contain peer MAC address.
    – Sergey
    May 27, 2022 at 6:08

1 Answer 1

3

If I'm not mistaken, ARP could be used to receive a MAC address of a machine. If you are connected at the data-link layer, I believe you can execute arp -an on a Linux machine to retrieve the MAC addresses of connected devices.

I've only used it to retrieve the MAC address associated with IP addresses, as that's what its usual function is - however due to the connectivity being over layer two, and that it uses the Ethernet broadcast address (FFFF.FFFF.FFFF), it should hopefully be able to retrieve the MAC address alone without an associated IP address.

I'm not actually able to test the above theory, but please let me know if you have any luck.

3
  • I'll have to dig out some cables and test yeah
    – Recct
    Sep 10, 2015 at 12:45
  • Accepted as it solves the problem because I had no complete knowledge of it, turns out the case is not as obscure as I thought and described in my original question.
    – Recct
    Sep 10, 2015 at 15:59
  • ARP stands for Address Resolution Protocol and it maps IP addresses to MAC addresses. It is not limited to layer 2, rather it is used for mapping Layer 3 addresses to Layer 2 addresses.
    – Shōgun8
    Apr 27, 2022 at 20:39

You must log in to answer this question.

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