Skip to main content

Get all interface IPs (device.ifaddrs)

Declaration

infos = device.ifaddrs()

Returns

  • infos
    Array | nil. On success returns a table with structure below; nil on failure

    Structure
    {
    {"ifname1", "ip1"},
    {"ifname2", "ip2"},
    ...
    }

Description

Get all interface IPs of the device

Example

-- Get Wi-Fi IP
local ip = "Wi-Fi is off"
for i, v in ipairs(device.ifaddrs()) do
if (v[1] == "en0") then
ip = v[2]
end
end
sys.alert(ip)

Note: Uses function outside this chapter sys.alert