Managing network interfaces from node.js

HiDefLoLife picture HiDefLoLife · Jul 18, 2015 · Viewed 7.2k times · Source

I am developing a node.js/express server application on Debian platform. I need to allow users to view and, importantly, change basic network settings: static/IP vs. auto/DHCP. I suppose I could use (and write the supporting code for):

cp.exec('ifconfig', function (err, ifConfigOut, stderr)

But I was wondering what the best practices are for doing this and if there was a recommended npm module (didn't seem to find any active ones)?

Answer

HiDefLoLife picture HiDefLoLife · Jul 22, 2015

Short answer, given the lack of responses and my googling: there appears to be no 'de facto' node module that provides the necessary services for managing network interfaces. I did find two that had some promise but are incomplete: https://github.com/FGRibreau/network-config and https://www.npmjs.com/package/ife.

EDIT: Of course you can always use https://nodejs.org/api/os.html#os_os_networkinterfaces to view existing interfaces, but if you want to change anything, core node does not appear to have the functionality.