All Projects → silverwind → default-gateway

silverwind / default-gateway

Licence: BSD-2-Clause license
Get the default network gateway, cross-platform.

Programming Languages

javascript
184084 projects - #8 most used programming language
Makefile
30231 projects

Projects that are alternatives of or similar to default-gateway

uac
UAC is a Live Response collection script for Incident Response that makes use of native binaries and tools to automate the collection of AIX, Android, ESXi, FreeBSD, Linux, macOS, NetBSD, NetScaler, OpenBSD and Solaris systems artifacts.
Stars: ✭ 260 (+237.66%)
Mutual labels:  freebsd, openbsd, solaris, aix
WendzelNNTPd
A usable and IPv6-ready Usenet-server (NNTP daemon). It is portable (Linux/*BSD/*nix), supports AUTHINFO authentication, contains ACL as well as role based ACL and provides "invisible" newsgroups. It can run on MySQL and SQLite backends.
Stars: ✭ 43 (-44.16%)
Mutual labels:  freebsd, openbsd, solaris
Punes
Nintendo Entertaiment System emulator and NSF/NSFe Music Player (Linux, FreeBSD, OpenBSD and Windows)
Stars: ✭ 217 (+181.82%)
Mutual labels:  freebsd, openbsd
Gnb
GNB is open source de-centralized VPN to achieve layer3 network via p2p with the ultimate capability of NAT Traversal.GNB是一个开源的去中心化的具有极致内网穿透能力的通过P2P进行三层网络交换的VPN。
Stars: ✭ 225 (+192.21%)
Mutual labels:  freebsd, openbsd
libcluon
libcluon is a small and efficient, single-file and header-only library written in modern C++ to power microservices.
Stars: ✭ 81 (+5.19%)
Mutual labels:  freebsd, openbsd
Durden
Desktop Environment for Arcan
Stars: ✭ 158 (+105.19%)
Mutual labels:  freebsd, openbsd
Objfw
[Official Mirror] A portable framework for the Objective-C language.
Stars: ✭ 161 (+109.09%)
Mutual labels:  freebsd, openbsd
newrelic-unix-monitor
Monitoring service for Unix (AIX, Linux, HP-UX, MacOS, Solaris) systems
Stars: ✭ 26 (-66.23%)
Mutual labels:  solaris, aix
Postinstall
💻 Bash Script to automate post-installation steps
Stars: ✭ 104 (+35.06%)
Mutual labels:  freebsd, openbsd
raptor infiltrate19
#INFILTRATE19 raptor's party pack
Stars: ✭ 27 (-64.94%)
Mutual labels:  solaris, aix
InitKit
Neo-InitWare is a modular, cross-platform reimplementation of the systemd init system. It is experimental.
Stars: ✭ 364 (+372.73%)
Mutual labels:  freebsd, openbsd
Mg
Micro (GNU) Emacs-like text editor ❤️ public-domain
Stars: ✭ 117 (+51.95%)
Mutual labels:  freebsd, openbsd
Fisy Fuzz
This is the full file system fuzzing framework that I presented at the Hack in the Box 2020 Lockdown Edition conference in April.
Stars: ✭ 110 (+42.86%)
Mutual labels:  freebsd, openbsd
Libtuntap
The portable Tun/Tap devices configuration utility
Stars: ✭ 107 (+38.96%)
Mutual labels:  freebsd, openbsd
gnb udp over tcp
gnb_udp_over_tcp 是一个为GNB开发的通过tcp链路中转UDP分组转发的服务
Stars: ✭ 32 (-58.44%)
Mutual labels:  freebsd, openbsd
Awesome Bsd
A collection of awesome BSD related stuff
Stars: ✭ 236 (+206.49%)
Mutual labels:  freebsd, openbsd
Zapret
Обход DPI в linux
Stars: ✭ 1,148 (+1390.91%)
Mutual labels:  freebsd, openbsd
Qtfm
Qt File Manager
Stars: ✭ 73 (-5.19%)
Mutual labels:  freebsd, openbsd
InitWare
The InitWare Suite of Middleware allows you to manage services and system resources as logical entities called units. Its main component is a service management ("init") system.
Stars: ✭ 164 (+112.99%)
Mutual labels:  freebsd, openbsd
cya
Easy to use snapshot and restore utility for any Linux (Unix) OS and filesystem powered by BASH
Stars: ✭ 73 (-5.19%)
Mutual labels:  freebsd, openbsd

default-gateway

Obtains the machine's default gateway through exec calls to OS routing interfaces.

  • On Linux and Android, the ip command must be available (usually provided by the iproute2 package).
  • On Windows, wmic must be available.
  • On IBM i, the db2util command must be available (provided by the db2util package).
  • On Unix (and macOS), the netstat command must be available.

Installation

$ npm i default-gateway

Example

const defaultGateway = require('default-gateway');

const {gateway, interface} = await defaultGateway.v4();
// gateway = '1.2.3.4', interface = 'en1'

const {gateway, interface} = await defaultGateway.v6();
// gateway = '2001:db8::1', interface = 'en2'

const {gateway, interface} = defaultGateway.v4.sync();
// gateway = '1.2.3.4', interface = 'en1'

const {gateway, interface} = defaultGateway.v6.sync();
// gateway = '2001:db8::1', interface = 'en2'

API

defaultGateway.v4()

defaultGateway.v6()

defaultGateway.v4.sync()

defaultGateway.v6.sync()

Returns: result Object

  • gateway: The IP address of the default gateway.
  • interface: The name of the interface. On Windows, this is the network adapter name.

The .v{4,6}() methods return a Promise while the .v{4,6}.sync() variants will return the result synchronously.

The gateway property will always be defined on success, while interface can be null if it cannot be determined. All methods reject/throw on unexpected conditions.

License

© silverwind, distributed under BSD licence

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].