Giter Site home page Giter Site logo

node-set-ip-address's Introduction

set-ip-address

Node module for setting up network interface(s) ip address.

Build Status

Supported linux network configurations:

  • dhcpcd (/etc/dhcpcd.conf)
  • ifdownup (/etc/network/interfaces)
  • netplan (/etc/netplan/)

Install

yarn add set-ip-address

OR

npm i --save set-ip-address

Basic Usage

var set_ip_address = require('set-ip-address')
var eth0 = {
  interface: 'eth0',
  ip_address: '10.0.0.1',
  prefix: 20,
  gateway: '10.0.0.1',
  nameservers: ['8.8.8.8'],
  optional: true // (netplan) - dont wait for interfaces to avoid boot delay
}

var eth1 {
  interface: 'eth1',
  dhcp: true
}

set_ip_address.configure([eth0, eth1]).then(() => console.log('done writing config files')

Configure VLAN

You can create vlan interface by passing vlanid option. Make sure to load 8021q module to the kernel:

sudo modprobe 8021q
var eth0 = {
  interface: 'eth0',
  ip_address: '10.0.0.1',
  prefix: 20,
  gateway: '10.0.0.1',
  nameservers: ['8.8.8.8']
}

var vlan1 {
  interface: 'eth0',
  vlanid: 10,
  ip_address: '20.0.0.1',
  prefix: 20,
  gateway: '20.0.0.1',
  nameservers: ['8.8.8.8']
}

set_ip_address.configure([eth0, vlan1]).then(() => console.log('done writing config files')

Configure Bridged Interfaces

var eth0 = {
  interface: 'eth0',
  manual: true
}

var vlan1 {
  interface: 'eth0',
  vlanid: 10,
  manual: true
}

var br0 = {
  interface: 'br0',
  ip_address: '10.0.0.1',
  prefix: 20,
  gateway: '10.0.0.1',
  nameservers: ['8.8.8.8'],
  bridge_ports: ['eth0', 'eth0.10'],
  bridge_opts: {
    stp: true
  }
}

set_ip_address
  .configure([eth0, vlan1, br0])
  .then(() => console.log('done writing config files')

Configure PPPoE Interface

var ppp = {
  provider: 'dsl-provider',
  physical_interface: 'eth0'
}

set_ip_address
  .configure([ppp])
  .then(() => console.log('done writing config files')

Restart Networking Service

set_ip_address.restartService()
  .then(() => console.log('network service restarted'))

LICENSE

MIT

node-set-ip-address's People

Contributors

adonespitogo avatar alenteria avatar jestillore avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.