Skip to content

Instantly share code, notes, and snippets.

@Icaruk
Created April 7, 2021 06:39
Show Gist options
  • Save Icaruk/8c38a0972bcc084674749d0b915813ee to your computer and use it in GitHub Desktop.
Save Icaruk/8c38a0972bcc084674749d0b915813ee to your computer and use it in GitHub Desktop.
Gets the IPv4
const networkInterfaces = require("os").networkInterfaces();
let IPv4;
Object.keys(networkInterfaces).forEach( device => {
networkInterfaces[device].forEach((details) => {
if (details.family === "IPv4" && details.internal === false) {
IPv4 = details.address;
};
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment