ip-addr-get.lua

#!/usr/bin/env eco

local addr = require 'eco.ip'.address
local socket = require 'eco.socket'

local ifname = 'eth0'

local res, err = addr.get(ifname)
if not res then
    print('get fail:', err)
    return
end

for _, info in pairs(res) do
    if info.family == socket.AF_INET then
        print(info.ifname, 'inet', info.scope)
        print('', info.address, info.broadcast)
    else
        print(info.ifname, 'inet6', info.scope)
        print('', info.address)
    end
    print()
end
generated by LDoc 1.5.0 Last updated 2026-04-09 14:48:22