Skip to content

Two awk scripts - one for updating Ubuntu 14 network interfaces file, one for reading the interfaces file

License

Notifications You must be signed in to change notification settings

relax-js/Network-Interfaces-Script

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

node-network-interfaces

This is a node Wrapper around Network-Interface-Script written by Joe Kuan. Allows you to read and update the contents of your /etc/network/interfaces file.

Concerns

This library is obviously only usable on systems that manage their network stack using /etc/network/interfaces although you can point the library at any file that has the same format.

More importantly - it depends on passwordless sudo for write access to the /etc/network/interfaces file. You will have to do the necessary work to enable this in your environment.

Finally, it depends on access to the tee command.

Usage

 const NetworkInterfaces = require('node-network-interfaces');

 const interfaces = new NetworkInterfaces('/absolute/path/to/my/interfaces/file');

 // Read the config for a given interface
 interfaces.currentConfig('eth0').then((interfaceConfig) => {
 	console.log(`Interface config was: ${interfaceConfig}`);
 }).catch((readError) => {
 	console.log(`Error reading config: ${readError}`);
 });

 // Write to the config for a given interface
 interfaces.setConfig('eth0', {
 	address: '192.168.2.12',
 	netmask: '255.255.255.0',
 	gateway: '192.168.2.1'
 }).then((newConfig) => {
 	console.log(`Config for eth0 is now ${newConfig}`);
 }).catch((configUpdateError) => {
 	console.log(`Failed to write config for eth0: ${configUpdateError}`);
 })

For usage sample and more information, see this blog. For updating DNS entry, see this blog.

About

Two awk scripts - one for updating Ubuntu 14 network interfaces file, one for reading the interfaces file

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 52.2%
  • Awk 47.8%