# network-config **Repository Path**: mirrors_FGRibreau/network-config ## Basic Information - **Project Name**: network-config - **Description**: Network configuration for NodeJS - **Primary Language**: Unknown - **License**: MIT - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2020-09-24 - **Last Updated**: 2026-07-04 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # network-config [![Deps](https://david-dm.org/FGRibreau/network-config.png)](https://david-dm.org/FGRibreau/network-config) [![Version](http://badge.fury.io/js/network-config.png)](https://david-dm.org/FGRibreau/network-config) [![Version](https://travis-ci.org/FGRibreau/network-config.svg)](https://travis-ci.org/FGRibreau/network-config) [![Downloads](http://img.shields.io/npm/dm/network-config.svg)](https://www.npmjs.com/package/network-config) [![Slack](https://img.shields.io/badge/Slack-Join%20our%20tech%20community-17202A?logo=slack)](https://join.slack.com/t/fgribreau/shared_invite/zt-edpjwt2t-Zh39mDUMNQ0QOr9qOj~jrg) Network configuration for NodeJS. **Only used & tested on Debian** # Setup ``` npm install network-config ```

## ❤️ Shameless plug - [Open-Source self-hostable or fully-managed **webhook as a service**](https://www.hook0.com/) - [**Charts, simple as a URL**. No more server-side rendering pain, 1 url = 1 chart](https://image-charts.com) - [Looking for a managed Keycloak IAM ?](https://www.cloud-iam.com/) # Usage ### List active interfaces To check the state of dhcp you have to enable parsing the interfaces file. ```javascript var network = require('network-config'); network.interfaces(function(err, interfaces){ /* interfaces should be something like: [{ name: 'eth0', ip: '1.1.1.77', netmask: '1.1.1.0', mac: 'aa:aa:aa:aa:aa:aa', gateway: '10.10.10.1', }, { ... }, { ... }] */ }); network.interfaces(function(err, interfaces){ /* interfaces should be something like: [{ name: 'eth0', ip: '1.1.1.77', netmask: '1.1.1.0', mac: 'aa:aa:aa:aa:aa:aa', gateway: '10.10.10.1', dhcp: false }, { ... }, { ... }] */ }, {interfaces: {parse: true, file: '/etc/network/interfaces'}}); //default: parse: false, file: '/etc/network/interfaces' // ipv6 support network.interfaces(function(err, interfaces){ /* interfaces should be something like: [{ name: 'enxb827ebf6e3b1', ip: '192.168.10.10', ip6: 'fe80::2866:af76:5fd6:11e2', ip6Gateway: 'fe80::dea6:32ff:fe63:b8f2', ip6prefixlen: '64', netmask: '255.255.255.0', broadcast: '192.168.10.255', mac: 'b8:27:eb:f6:e3:b1', gateway: '192.168.10.1' }, { name: 'lo', ip: '127.0.0.1', ip6: '::1', ip6Gateway: 'fe80::dea6:32ff:fe63:b8f2', ip6prefixlen: '128', netmask: '255.0.0.0', broadcast: null, mac: null, gateway: '192.168.10.1' }, { name: 'rename3', ip: null, ip6Gateway: 'fe80::dea6:32ff:fe63:b8f2', netmask: null, broadcast: null, mac: "b8:27:eb:f6:e3:b1", gateway: '192.168.10.1' }] */ }, {gateway: {resolveHostNames: false, route6: true}}); ``` ### Update interface (static) ``` network.configure('eth0', { ip: 'x.x.x.x', netmask:'x.x.x.x', broadcast: 'x.x.x.x', gateway: 'x.x.x.x', restart: true // (default) restart networking service right away }, function(err){ }) ``` ### Update interface (dhcp) ```javascript network.configure('eth0', { dhcp: true, restart: false // don't restart networking service }, function(err){ }); ``` # [Changelog](/CHANGELOG.md)