M
os.networkInterfaces
History
Added in: v0.6.0
v0.6.0
Introduced in: v0.10.0
v0.10.0
The
family property now returns a string instead of a number.v18.4.0
The
family property now returns a number instead of a string.v18.0.0
os.networkInterfaces(): Object
Returns:
ObjectReturns an object containing network interfaces that have been assigned a network address.
Each key on the returned object identifies a network interface. The associated value is an array of objects that each describe an assigned network address.
The properties available on the assigned network address object include:
Attributes
address:
stringThe assigned IPv4 or IPv6 address
netmask:
stringThe IPv4 or IPv6 network mask
family:
stringEither
IPv4 or IPv6mac:
stringThe MAC address of the network interface
internal:
booleantrue if the network interface is a loopback or
similar interface that is not remotely accessible; otherwise falsescopeid:
numberThe numeric IPv6 scope ID (only specified when
family
is IPv6)cidr:
stringThe assigned IPv4 or IPv6 address with the routing prefix
in CIDR notation. If the
netmask is invalid, this property is set
to null.{ "lo": [ { "address": "127.0.0.1", "netmask": "255.0.0.0", "family": "IPv4", "mac": "00:00:00:00:00:00", "internal": true, "cidr": "127.0.0.1/8" }, { "address": "::1", "netmask": "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff", "family": "IPv6", "mac": "00:00:00:00:00:00", "scopeid": 0, "internal": true, "cidr": "::1/128" } ], "eth0": [ { "address": "192.168.1.108", "netmask": "255.255.255.0", "family": "IPv4", "mac": "01:02:03:0a:0b:0c", "internal": false, "cidr": "192.168.1.108/24" }, { "address": "fe80::a00:27ff:fe4e:66a1", "netmask": "ffff:ffff:ffff:ffff::", "family": "IPv6", "mac": "01:02:03:0a:0b:0c", "scopeid": 1, "internal": false, "cidr": "fe80::a00:27ff:fe4e:66a1/64" } ] }