2

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)?

2 Answers 2

5

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.

Sign up to request clarification or add additional context in comments.

Comments

2

Maybe is a bit past the expiration date, but here's my take on it:

The main problem on writing it using in-built config tools like "ifconfig" is that many modern OSes are bypassing ifconfig for other modules (like netplan) so you may find that upgrading the system breaks your network config app, like it happened to me (I wrote a parser for the /network/interfaces but now I have to modify it for netplan).

node-ife brings interface management for Linux, BSD and MacOS (does not work on windows though) that is not dependent on OS config tools, but doesn't seem to be compatible with Node 10, and seems to be a bit dead. Wireless tools, though the name is a bit misleading, seems to incorporate ifconfig capabilities that may suit you better

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.