Socket
Socket
Sign inDemoInstall

default-gateway

Package Overview
Dependencies
1
Maintainers
1
Versions
54
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    default-gateway

Get the default network gateway, cross-platform.


Version published
Maintainers
1
Install size
13.4 kB
Created

Package description

What is default-gateway?

The default-gateway npm package provides a simple and efficient way to find the default gateway of the local machine's network interfaces. It supports multiple operating systems, including Windows, macOS, and Linux, making it a versatile tool for network-related programming tasks. This package can be particularly useful for applications that need to interact with the network layer of the operating system, such as determining the best route for network traffic or configuring network settings programmatically.

What are default-gateway's main functionalities?

Finding the default gateway for IPv4

This feature allows you to asynchronously find the default IPv4 gateway of the local machine. The result is an object containing the gateway's IP address and the associated network interface.

const defaultGateway = require('default-gateway');
defaultGateway.v4().then(result => console.log(result));

Finding the default gateway for IPv6

Similar to the IPv4 feature, this allows for the asynchronous discovery of the default IPv6 gateway. The result includes the IPv6 gateway address and the network interface it is associated with.

const defaultGateway = require('default-gateway');
defaultGateway.v6().then(result => console.log(result));

Other packages similar to default-gateway

Readme

Source

default-gateway

Get the default network gateway, cross-platform.

Obtains the network gateway through exec calls to OS routing interfaces. Supports Linux, macOS and Windows. On Linux, the ip command must be available (usually provided by the iproute2 package).

Installation

$ npm install --save default-gateway

Example

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'}
});

API

default-gateway.v4()

Returns a promise that resolves to a object containing the IPv4 gateway and interface. If it succeeds, gateway will always be defined, while interface can be absent. Rejects when the gateway cannot be determined.

default-gateway.v6()

Returns a promise that resolves to a object containing the IPv6 gateway and interface. If it succeeds, gateway will always be defined, while interface can be absent. Rejects when the gateway cannot be determined.

© silverwind, distributed under BSD licence

Keywords

FAQs

Last updated on 25 Jun 2017

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc