2

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.

  • 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 '15 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 '15 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. – Incnis Mrsi Sep 10 '15 at 12:24
  • It depends on how the unconfigured router behaves. Will it accept and send packets, or not send anything until configured? If you can tell us the router model that will help. – Mark Plotnick Sep 10 '15 at 13:45
  • 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. – Mark Plotnick Sep 10 '15 at 15:29
2

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 address of connected devices. I've only used it to retrieve the MAC address associated with IP addresses, as that's what it's 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.

  • I'll have to dig out some cables and test yeah – Recct Sep 10 '15 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 '15 at 15:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.