| Crates.io | r-lancli |
| lib.rs | r-lancli |
| version | 0.1.5 |
| created_at | 2025-08-12 16:19:02.193889+00 |
| updated_at | 2025-08-14 17:04:45.017056+00 |
| description | A command-line interface for performing network scanning operations on local area networks (LANs) |
| homepage | https://github.com/robgonnella/r-lanscan |
| repository | https://github.com/robgonnella/r-lanscan |
| max_upload_size | |
| id | 1792204 |
| size | 64,213 |
A command-line interface for performing network scanning operations on local area networks (LANs). This CLI tool uses the r-lanlib library to provide comprehensive network reconnaissance capabilities.
# Clone the repository
git clone https://github.com/robgonnella/r-lanscan
cd r-lanscan
# Build the CLI tool
cargo build --release -p r-lancli
# The binary will be available at ./target/release/r-lancli
Scan your entire local network (discovers devices and scans all ports):
sudo r-lancli
Quickly discover devices without port scanning:
sudo r-lancli --arp-only --vendor --host-names
Scan specific IP addresses or ranges:
sudo r-lancli --targets 192.168.1.1,192.168.1.10-20,10.0.0.0/24
Scan only common ports:
sudo r-lancli --ports 22,80,443,8080,8443
Get results in JSON format for scripting:
sudo r-lancli --json --quiet > scan_results.json
--targets, -t <TARGETS>Comma-separated list of scan targets. Supports:
192.168.1.1192.168.1.1-192.168.1.100192.168.1.0/24, 10.0.0.0/16Default: Uses the CIDR block of the selected network interface
Examples:
# Single IP
sudo r-lancli --targets 192.168.1.1
# Multiple IPs
sudo r-lancli --targets 192.168.1.1,192.168.1.5,192.168.1.10
# IP range
sudo r-lancli --targets 192.168.1.1-192.168.1.50
# CIDR block
sudo r-lancli --targets 192.168.1.0/24
# Mixed specification
sudo r-lancli --targets 192.168.1.1,192.168.1.10-20,10.0.0.0/24
--ports, -p <PORTS>Comma-separated list of ports and port ranges to scan.
Default: 1-65535 (all ports)
Examples:
# Common ports
sudo r-lancli --ports 22,80,443
# Port ranges
sudo r-lancli --ports 1-1000,8000-9000
# Mixed specification
sudo r-lancli --ports 22,80,443,8000-9000,3389
--arp-onlyPerform only ARP scanning, skipping SYN port scanning.
Use case: Quick device discovery without the time overhead of port scanning.
sudo r-lancli --arp-only --vendor --host-names
--vendorEnable MAC address vendor lookup to identify device manufacturers.
sudo r-lancli --vendor
--host-namesEnable reverse DNS lookup to resolve hostnames for discovered devices.
sudo r-lancli --host-names
--interface, -i <INTERFACE>Select a specific network interface for scanning.
Default: Automatically selects the default network interface
Examples:
# Use specific interface
sudo r-lancli --interface eth0
# List available interfaces (use system tools)
ip link show # Linux
ifconfig # macOS/BSD
--source-port <SOURCE_PORT>Set the source port for outgoing scan packets.
Default: Automatically selects an available port
sudo r-lancli --source-port 12345
--jsonOutput results in JSON format instead of human-readable tables.
Use case: Programmatic processing, integration with other tools.
sudo r-lancli --json > results.json
--quiet, -qSuppress progress messages, only show final results.
Use case: Cleaner output for scripting and automation.
sudo r-lancli --quiet --json
--idle-timeout-ms <MILLISECONDS>Set the idle timeout for scan operations.
Default: 10000 (10 seconds)
Use case: Adjust for slower networks or more thorough scanning.
# Faster scanning (less thorough)
sudo r-lancli --idle-timeout-ms 5000
# Slower scanning (more thorough)
sudo r-lancli --idle-timeout-ms 30000
--debugEnable debug logging for troubleshooting scan operations.
sudo r-lancli --debug
ARP Results:
+---------------+----------+-------------------+------------------------+
| IP | HOSTNAME | MAC | VENDOR |
+---------------+----------+-------------------+------------------------+
| 192.168.1.1 | router | aa:bb:cc:dd:ee:ff | Netgear |
| 192.168.1.100 | laptop | 11:22:33:44:55:66 | Apple, Inc. |
| 192.168.1.150 | | 99:88:77:66:55:44 | Samsung Electronics |
+---------------+----------+-------------------+------------------------+
SYN Results (with port scanning):
+---------------+----------+-------------------+------------------------+-------------+
| IP | HOSTNAME | MAC | VENDOR | OPEN_PORTS |
+---------------+----------+-------------------+------------------------+-------------+
| 192.168.1.1 | router | aa:bb:cc:dd:ee:ff | Netgear | 22, 80, 443 |
| 192.168.1.100 | laptop | 11:22:33:44:55:66 | Apple, Inc. | 22, 5900 |
+---------------+----------+-------------------+------------------------+-------------+
[
{
"hostname": "router",
"ip": "192.168.1.1",
"mac": "aa:bb:cc:dd:ee:ff",
"vendor": "Netgear",
"is_current_host": false,
"open_ports": [
{ "id": 22, "service": "ssh" },
{ "id": 80, "service": "http" },
{ "id": 443, "service": "https" }
]
}
]
Discover all devices on your local network:
sudo r-lancli --arp-only --vendor --host-names
Comprehensive scan with detailed information:
sudo r-lancli --vendor --host-names --json > network_audit.json
Find devices running specific services:
sudo r-lancli --ports 22,80,443,3389,5900 --vendor
Check if specific hosts have certain ports open:
sudo r-lancli --targets 192.168.1.1,192.168.1.100 --ports 22,80,443
Scan multiple subnets:
sudo r-lancli --targets 192.168.1.0/24,192.168.2.0/24 --arp-only
#!/bin/bash
# Perform scan and save results
sudo r-lancli --json --quiet > network_scan.json
# Process results with jq
jq '.[] | select(.open_ports | length > 0)' network_scan.json > devices_with_ports.json
echo "Found $(jq 'length' devices_with_ports.json) devices with open ports"
import json
import subprocess
# Run scan
result = subprocess.run([
'sudo', 'r-lancli',
'--json', '--quiet',
'--targets', '192.168.1.0/24'
], capture_output=True, text=True)
# Parse results
devices = json.loads(result.stdout)
for device in devices:
print(f"Device: {device['ip']} ({device['hostname']})")
if 'open_ports' in device:
ports = [str(port['id']) for port in device['open_ports']]
print(f" Open ports: {', '.join(ports)}")
# Add to crontab for periodic scanning
# Run every hour and log changes
0 * * * * /usr/local/bin/r-lancli --json --quiet > /var/log/network-scan-$(date +\%Y\%m\%d-\%H).json 2>&1
Error: permission denied: must run with root privileges
Solution: Run with sudo:
sudo r-lancli
Error: cannot find interface
Solutions:
List available interfaces:
# Linux
ip link show
# macOS/BSD
ifconfig
Specify interface explicitly:
sudo r-lancli --interface eth0
Possible causes:
Solutions:
Increase timeout:
sudo r-lancli --idle-timeout-ms 30000
Use debug mode:
sudo r-lancli --debug
Verify network configuration:
# Check your IP and network
ip route show # Linux
route -n get default # macOS
For large networks:
Use ARP-only for initial discovery:
sudo r-lancli --arp-only
Limit port ranges:
sudo r-lancli --ports 1-1000
Scan smaller subnets:
sudo r-lancli --targets 192.168.1.0/26
This project is dual-licensed under either of
at your option.