Skip to content

Instantly share code, notes, and snippets.

@leptoquark1
Last active May 4, 2024 17:19
Show Gist options
  • Select an option

  • Save leptoquark1/51a7836e67938606d391bf3600de5a89 to your computer and use it in GitHub Desktop.

Select an option

Save leptoquark1/51a7836e67938606d391bf3600de5a89 to your computer and use it in GitHub Desktop.
NodeJS - Get relevant Local IP-Address to further determ subnet
function getLocalIpAddress() {
return Object.values(os.networkInterfaces())
.flat()
.filter(ifq => ifq.family === 'IPv4' && !ifq.internal && ifq.mac !== '00:00:00:00:00:00')
.map(ifq => ({ address: ifq.address, cidr: ifq.cidr }));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment