System-level utilities for network configuration, ARP tables, routing, and data conversions.

Methods

(async, static) gatewayFor(dstIpopt) → {Promise.<(GatewayInfo|null)>}

Determines the appropriate gateway IP address and network interface required to reach a specific destination IP. If no destination IP is provided, it returns the default gateway.
Parameters:
NameTypeAttributesDefaultDescription
dstIpstring | null<optional>
nullThe target IP address (IPv4 or IPv6) to route to.
Returns:
An object with gateway details, or null if no route is found.
Type: 
Promise.<(GatewayInfo|null)>
Example
const { system } = require('over-the-wire');

// Find route to Google's IPv4
const gw4 = await system.gatewayFor('216.58.209.78');
console.log(gw4); // { iface: 'eth0', ip: '192.168.1.1', family: 'AF_INET' }

// Find route to Google's IPv6
const gw6 = await system.gatewayFor('2a00:1450:4001:810::200e');
console.log(gw6); // { iface: 'eth0', ip: 'fe80::1', family: 'AF_INET6' }

(async, static) getArpTable() → {Promise.<Object>}

Retrieves the ARP (Address Resolution Protocol) table for all interfaces.
Source
Returns:
An object where the keys are interface names and the values are arrays of ARP records. Each ARP record is represented by an object with `ipAddr` (IP address) and `hwAddr` (hardware address) properties.
Type: 
Promise.<Object>
Example
const arpTable = await getArpTable();
// arpTable = {
//   eth0: [
//     { ipAddr: '192.168.1.1', hwAddr: '00:1A:2B:3C:4D:5E' },
//     { ipAddr: '192.168.1.2', hwAddr: '00:1A:2B:3C:4D:5F' }
//   ],
//   wlan0: [
//     { ipAddr: '192.168.1.3', hwAddr: '00:1A:2B:3C:4D:60' }
//   ]
// }

(async, static) getRoutingTable() → {Promise.<Object.<string, Array.<RouteEntry>>>}

Retrieves the system's IP routing table.
Returns:
An object mapping interface names to arrays of route entries.
Type: 
Promise.<Object.<string, Array.<RouteEntry>>>