How to get device mac when device accessing admin page? Like merlin's "Clone mac" button

I want to write a small tool to clone the mac of the device that accessing the admin page, so first I should get the mac of the device that accessing the admin page, help me how to code this lua pls!

every device, or just one specific device ?

just one device when I currently login to the admin page from browser, I want to get mac of this device.

Just like the Merlin firmware, Have a "Clone mac" button to get device mac.

You can obviously get the MAC from the status page, since it shows all connected devices, or from the device itself, but there's no clone MAC button, AFAIK.

1 Like

But for example, if the secondary router is connected to openwrt, openwrt cannot get device mac under the secondary router‘s device, even I can login to admin page, I can't get my mac in status page.

yes

that is correct, then you'll only see it on the router closest to the device.

2 Likes

The MAC addresses that the kernel knows about are stored in the ARP table, which can be seen in LuCI Status-->Routes. You'd have to match the entry with the http client's IP address to find the PC that is accessing LuCI.

As @frollic said, MAC addresses aren't carried through a layer 3 route. If there are two routers in series the upstream router uses the MAC of the downstream router to send everything to it.

1 Like

Thx!! Can you teach me how to write this plugin?

Is it possible to get the user ip that has been logged in to the admin page?

Then compare ARP table and IP to get mac?

@frollic @mk24

The arp table/command contains/shows the IP of every MAC the device is familiar with.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.