0.0
The project is in a healthy, maintained state
The ruby gem to scan your LAN for devices
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.0
>= 10.0
>= 3.0

Runtime

~> 1.15
~> 0.1.3
~> 0.5
 Project Readme

lan_scanner

Gem downloads License: MIT

The very basic ruby gem to scan your LAN for devices

Based on nmap.

Contents

  • Usage
  • Installation
  • Documentation
  • Contributing

Usage

Find online devices in LAN

require 'lan_scanner'

# examples with explicit default parameters
devices = LanScanner.scan_devices network: '192.168.178.0/24'
# => [LanScanner::Device, LanScanner::Device, ...]

devices.each do |d|
  puts "=================================================="
  puts "Found device on #{d.remote_address}"
  puts
  puts "Hostname: #{d.host_name}"
  puts
  # =================================================="
  # Found device on 192.168.178.20
  # 
  # Hostname: Windows-PC
  # 
end

Get state of devices in LAN

require 'lan_scanner'

devices = LanScanner.scan_device_states %w[192.168.178.1 192.168.178.22 192.168.178.44], expensive: true
# => [LanScanner::Device, LanScanner::Device, ...]

devices.each do |d|
  puts "#{d.remote_address} -> #{d.host_name} (#{d.state})"
end
# 192.168.178.1 -> server.domain (up)
# 192.168.178.22 -> mycomputer.domain (up)
# 192.168.178.44 -> (down)

Installation

NMAP

This gem is based on nmap. So you need to install nmap before and ensure it is available via command line (added to PATH environment variable).

To check if you have installed nmap correctly, run the following command on a terminal

nmap --version

and you should get some version information. After, you are ready to install the ruby gem.

Gem

Add this line to your application's Gemfile:

gem 'lan_scanner'

And then execute:

$ bundle install

Or install it yourself by:

$ gem install lan_scanner

Documentation

Check out the doc at RubyDoc https://www.rubydoc.info/gems/lan_scanner

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/magynhard/lan_scanner. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.