#!/usr/bin/lua local util = require "luci.util" local jsonc = require "luci.jsonc" local eth_info = {} local ifname, stat for ifname, stat in pairs(util.ubus("network.device", "status")) do if ifname:match("^(eth%d+)$") == ifname or ifname:match("^(usb%d+)$") or ifname:match("^(lan%d+)$") or ifname:match("wan") == ifname then eth_info[#eth_info + 1] = { device = ifname } end end table.sort( eth_info, function(a, b) return a.device < b.device end ) print(jsonc.stringify(eth_info))