Skip to content

magynhard/lan_scanner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

lan_scanner

Gem downloads License: MIT

The very basic ruby gem to scan your LAN for devices

Based on nmap.

Contents

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.

About

The very basic ruby gem to scan your LAN for devices

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published