|
function mac(iface)
if not iface then
return nil, 'no interface'
end
local f = io.open('/proc/net/arp', 'r')
if not f then
return nil, 'open error'
end
local match = string.format('%%x*:.*%s', iface)
local mac = string.match(tostring(f:read('*a')), match)
if mac then return mac:sub(1, 17), nil end
end
print(mac("eth0"))