Find devices connected to the current local network.
npm install local-devices[![version][version-badge]][package]
[![MIT License][license-badge]][licence]


[![PRs Welcome][prs-badge]][prs]
[![Build Status][build-badge]][build]
[![Coverage Status][coverage-badge]][coverage]
[![Watch on GitHub][github-watch-badge]][github-watch]
[![Star on GitHub][github-star-badge]][github-star]
Find all devices connected to the local network using arp -a.
This module also pings all possible ip's in the local network to build the arp table.
``console`
npm install local-devices
`javascript
// Using a transpiler
import find from 'local-devices'
// Without using a transpiler
const find = require('local-devices');
// Find all local network devices.
find().then(devices => {
devices /*
[
{ name: '?', ip: '192.168.0.10', mac: '...' },
{ name: '...', ip: '192.168.0.17', mac: '...' },
{ name: '...', ip: '192.168.0.21', mac: '...' },
{ name: '...', ip: '192.168.0.22', mac: '...' }
]
*/
})
// Find a single device by ip address.
find({ address: '192.168.0.10' }).then(device => {
device /*
{
name: '?',
ip: '192.168.0.10',
mac: '...'
}
*/
})
// Find all devices within 192.168.0.1 to 192.168.0.25 range
find({ address: '192.168.0.1-192.168.0.25' }).then(devices => {
devices /*
[
{ name: '?', ip: '192.168.0.10', mac: '...' },
{ name: '...', ip: '192.168.0.17', mac: '...' },
{ name: '...', ip: '192.168.0.21', mac: '...' },
{ name: '...', ip: '192.168.0.22', mac: '...' }
]
*/
})
// Find all devices within /24 subnet range of 192.168.0.x
find({ address: '192.168.0.0/24' }).then(devices => {
devices /*
[
{ name: '?', ip: '192.168.0.10', mac: '...' },
{ name: '...', ip: '192.168.0.50', mac: '...' },
{ name: '...', ip: '192.168.0.155', mac: '...' },
{ name: '...', ip: '192.168.0.211', mac: '...' }
]
*/
})
// Find all devices without resolving host names (Uses 'arp -an') - this is more performant if hostnames are not needed
// (This flag is ignored on Windows machines as 'arp -an' is not supported)
find({ skipNameResolution: true }).then(devices => {
devices /*
[
{ name: '?', ip: '192.168.0.10', mac: '...' },
{ name: '?', ip: '192.168.0.50', mac: '...' },
{ name: '?', ip: '192.168.0.155', mac: '...' },
{ name: '?', ip: '192.168.0.211', mac: '...' }
]
*/
})
// Find all devices, specifying your own path for the arp binary `
find({ arpPath: '/usr/sbin/arp' }).then(devices => {
devices /*
[
{ name: '?', ip: '192.168.0.10', mac: '...' },
{ name: '?', ip: '192.168.0.50', mac: '...' },
{ name: '?', ip: '192.168.0.155', mac: '...' },
{ name: '?', ip: '192.168.0.211', mac: '...' }
]
*/
})`
* Use npm test to run tests.
Please feel free to create a PR!
Thanks goes to these wonderful people ([emoji key][emojis]):
Dylan Piercey 💻 💡 👀 📖 🤔 💬 | Stefan Natter 💻 ⚠️ 🐛 📖 🤔 | kounelios13 🐛 📖 | MarkusSuomi 💻 | Xavier Martin 💻 | howel52 💻 🐛 | LucaSoldi 💻 🐛 |
Miosame 💻 📖 💡 | Tim Rogers 💻 📖 ⚠️ |
This project follows the [all-contributors][all-contributors] specification.
Contributions of any kind are welcome!
Contributors can be added with the all-contributors cli.
The cli is already installed and can be used like this:
`bash``
yarn all-contributors add
[package]: https://www.npmjs.com/package/local-devices
[licence]: https://github.com/DylanPiercey/local-devices/blob/master/LICENCE
[prs]: http://makeapullrequest.com
[github-watch]: https://github.com/DylanPiercey/local-devices/watchers
[github-star]: https://github.com/DylanPiercey/local-devices/stargazers
[github-watch-badge]: https://img.shields.io/github/watchers/DylanPiercey/local-devices.svg?style=social
[github-star-badge]: https://img.shields.io/github/stars/DylanPiercey/local-devices.svg?style=social
[version-badge]: https://img.shields.io/npm/v/local-devices.svg?style=flat-square
[license-badge]: https://img.shields.io/npm/l/local-devices.svg?style=flat-square
[prs-badge]: https://img.shields.io/badge/PRs-welcome-brightgreen.svg?style=flat-square
[emojis]: https://github.com/kentcdodds/all-contributors#emoji-key
[all-contributors]: https://github.com/kentcdodds/all-contributors
[build-badge]: https://travis-ci.org/DylanPiercey/local-devices.svg?branch=master
[build]: https://travis-ci.org/DylanPiercey/local-devices
[coverage-badge]: https://coveralls.io/repos/github/DylanPiercey/local-devices/badge.svg?branch=master
[coverage]: https://coveralls.io/github/DylanPiercey/local-devices?branch=master