11.01.2021, 08:03
You can get a list table with IP -> MAC mapping from the ARP table like this:
Name is a part of DHCP and only the DHCP server / router has this information.
Code:
macs = {}
lines = io.readfile('/proc/net/arp'):split('\n')
-- skip first and last line
for i = 2, #lines - 1 do
ip, _, _, mac = unpack(lines[ i ]:gsub('%s+', ' '):split(' '))
macs[ ip ] = mac
end
log(macs)
Name is a part of DHCP and only the DHCP server / router has this information.