Skip to main content
Version: Next

Network

Network management API allows you to manually set network interfaces or set back DHCP and current active network info.

All methods

MethodDescriptionSupported since
getActiveInfo()Information about network interfaces, IP addesses and MAC addresses (DEPRECATED)4.0
listInterfaces()Information about network interfaces4.9
setManual()Allows you to set network settings manually4.0
setDHCP()Allows you to set network settings automatically from DHCP4.0
disableInterface()Disables a network interface4.13

getActiveInfo()

Method getActiveInfo() will display information about connected network.

warning

This method is deprecated. Use listInterfaces() instead.

Javascript example

await sos.management.network.getActiveInfo();

Example of response

{
"activeInterface": "ethernet",
"dns": [
"192.168.1.1",
"1.1.1.1"
],
"gateway": "192.168.1.1",
"localAddress": "192.168.1.137",
"ethernetMacAddress": "b8:27:eb:25:8f:63",
"wifiMacAddress": "b8:27:eb:25:8f:63",
"netmask": "255.255.255.0"
}

Wifi connection strength is described as percentage in range from 0 to 100, linearly converted from dBm -90 to -30 respectively based on platform.

{
"activeInterface": "wifi",
"dns": [
"192.168.1.1",
"1.1.1.1"
],
"gateway": "192.168.1.1",
"localAddress": "192.168.1.137",
"ethernetMacAddress": "b8:27:eb:25:8f:63",
"wifiMacAddress": "b8:27:eb:25:8f:63",
"netmask": "255.255.255.0",
"wifiSsid": "hotel",
"wifiStrength": "87"
}

listInterfaces()

Returns list of all network interfaces, and their information like MAC address, IP address, etc.

Javascript example

const interfaces = await sos.management.network.listInterfaces();

Example of response

Wifi connection strength is described as percentage in range from 0 to 100, linearly converted from dBm -90 to -30 respectively based on platform.

[
{
"type": "ethernet",
"name": "eth0",
"macAddress": "b8:27:eb:25:8f:63",
"localAddress": "192.168.1.137",
"gateway": "192.168.1.1",
"netmask": "255.255.255.0",
"dns": [
"192.168.1.1",
"1.1.1.1"
]
},
{
"type": "wifi",
"name": "wlan0",
"macAddress": "b8:27:eb:25:8f:63",
"localAddress": "192.168.1.138",
"gateway": "192.168.1.1",
"netmask": "255.255.255.0",
"dns": [
"192.168.1.1",
"1.1.1.1"
],
"wifiSsid": "hotel",
"wifiStrength": "87"
}
]

setManual()

Manually configures a network interface. If the interface is disabled, it will be enabled.

warning

Wi-Fi interface can be configured with this method but it has to be first enabled via the Wi-Fi API.

Object properties

New way

NameTypeRequiredDescription
interfaceNameString
Yes
Network interface name, can be retrieved from listInterfaces()
options.localAddressString
Yes
Network local address
options.gatewayString
Yes
Network gateway
options.netmaskString
Yes
Network netmask
options.dnsArray
Yes
Array of additionally DNSs

Old way (deprecated)

NameTypeRequiredDescription
interfaceString
Yes
Network type interface, can be only ethernet or wifi
localAddressString
Yes
Network local address
gatewayString
Yes
Network gateway
netmaskString
Yes
Network netmask
dnsArray
Yes
Array of additionally DNSs

Javascript example

// new way
await sos.management.network.setManual('eth0', {
localAddress: '192.168.1.133',
gateway: '192.168.1.1',
netmask: '255.255.255.0',
dns: ['8.8.8.8', '192.168.1.1'],
});

// old way (deprecated)
await sos.management.network.setManual({
interface: 'ethernet',
localAddress: '192.168.1.133',
gateway: '192.168.1.1',
netmask: '255.255.255.0',
dns: ['8.8.8.8', '192.168.1.1'],
});

setDHCP()

Configures a network interface to use DHCP to get an IP address asigned from the network. If the interface is disabled, it will be enabled.

warning

Wi-Fi interface can be configured with this method but it has to be first enabled via the Wi-Fi API.

Object properties

New way

NameTypeRequiredDescription
interfaceNameString
Yes
Network interface name, can be retrieved from listInterfaces()

Old way (deprecated)

NameTypeRequiredDescription
networkInterfaceString
Yes
Network type interface, can be only ethernet or wifi

Javascript example

// new way
await sos.management.network.setDHCP('eth0');

// old way (deprecated)
await sos.management.network.setDHCP('ethernet');

disableInterface()

Disables a network interface

ParamTypeRequiredDescription
interfaceNameString
Yes
Name of the network interface, that will be disabled

Javascript example

await sos.management.wifi.disableInterface("eth0");
info

A disabled network interface can be re-enabled simply by calling either setDHCP() or setManual().

warning

Don't use this method to disable Wi-Fi. Use Wi-Fi API to enable/disable Wi-Fi.