
Company News
Socket Has Acquired Secure Annex
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.
default-gateway
Advanced tools
Get the default network gateway, cross-platform.
Obtains the machine's default gateway through exec calls to OS routing interfaces. Supports Linux, macOS and Windows and Android. On Linux and Android, the ip command must be available (usually provided by the iproute2 package).
$ npm install default-gateway
const defaultGateway = require('default-gateway');
defaultGateway.v4().then(result => {
//=> {gateway: '1.2.3.4', interface: 'en1'}
});
defaultGateway.v6().then(result => {
//=> {gateway: '2001:db8::1', interface: 'en2'}
});
Returns a promise that resolves to a object containing the IPv4 gateway and interface properties. If it succeeds, gateway will always be defined, while interface can be null if it cannot be determined. Rejects when the gateway cannot be determined.
Returns a promise that resolves to a object containing the IPv6 gateway and interface properties. If it succeeds, gateway will always be defined, while interface can be null if it cannot be determined. Rejects when the gateway cannot be determined.
© silverwind, distributed under BSD licence
The 'ip' package provides utilities for handling IP addresses, including the ability to parse and format them. While it doesn't offer direct functionality to find the default gateway, it complements 'default-gateway' by providing tools to work with the IP addresses that 'default-gateway' might return.
The 'network' package offers a broader range of network-related functionalities, including getting the user's IP address, gateway, and active network interfaces. It serves a similar purpose to 'default-gateway' but with additional features that might be useful for more comprehensive network programming tasks.
While not a third-party package but a core Node.js module, 'os' provides basic operating system-related utility functions. It includes methods to retrieve network interface details. However, it does not directly provide the default gateway information, making 'default-gateway' a necessary complement for specific gateway-related tasks.
FAQs
Get the default network gateway, cross-platform.
The npm package default-gateway receives a total of 8,147,412 weekly downloads. As such, default-gateway popularity was classified as popular.
We found that default-gateway demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Company News
Socket has acquired Secure Annex to expand extension security across browsers, IDEs, and AI tools.

Research
/Security News
Socket is tracking cloned Open VSX extensions tied to GlassWorm, with several updated from benign-looking sleepers into malware delivery vehicles.

Product
Reachability analysis for PHP is now available in experimental, helping teams identify which vulnerabilities are actually exploitable.