netplan-js

1.0.3 • Public • Published

Netplan-JS - read and update netplan configurations

This is Node JS library for reading Netplan configurations and updating config files from NodeJS applications.

Installation

npm install netplan-js

Usage

Reading Netplan configurations:

const Netplan = require('netplan-js');

const netplan = new Netplan();
netplan.loadConfigs().then(() => {
  const config = netplan.getInterface('ethernets', 'ens33');
  console.log('Current config:', JSON.stringify(config));
});

Updating Netplan configurations:

const Netplan = require('netplan-js');

const netplan = new Netplan();
netplan.loadConfigs().then(() => {
  netplan.setInterface('ethernets', 'ens33', {
    dhcp4: false,
    addresses: ['192.168.1.105/24'],
    nameservers: { addresses: ['192.168.1.1'] },
    gateway4: '192.168.1.1',
  });
  netplan.writeConfigs().then(() => {
    netplan.apply()
      .then(() => console.log('Success'))
      .catch((err) => console.error(err.message));
  });
});

Readme

Keywords

none

Package Sidebar

Install

npm i netplan-js

Weekly Downloads

13

Version

1.0.3

License

MIT

Unpacked Size

10.1 kB

Total Files

8

Last publish

Collaborators

  • bladerunner2020