r-lancli
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.
Features
- ARP Scanning: Discover active devices on your network using Address Resolution Protocol
- SYN Port Scanning: Detect open ports on discovered devices using TCP SYN packets
- Flexible Target Specification: Support for individual IPs, IP ranges, and CIDR blocks
- Port Range Scanning: Scan specific ports or port ranges
- Device Information: Optional MAC address vendor lookup and hostname resolution
- Multiple Output Formats: Human-readable tables or JSON for programmatic use
- Network Interface Selection: Choose specific network interfaces for scanning
- Configurable Timeouts: Adjust scan timing for different network conditions
Installation
Prerequisites
- Root privileges required: Network scanning requires raw socket access
- Rust 1.89.0+ - Install via rustup.rs
Building from Source
# Clone the repository
# Build the CLI tool
# The binary will be available at ./target/release/r-lancli
Quick Start
Basic Network Scan
Scan your entire local network (discovers devices and scans all ports):
ARP-Only Device Discovery
Quickly discover devices without port scanning:
Scan Specific Targets
Scan specific IP addresses or ranges:
Port-Specific Scanning
Scan only common ports:
JSON Output
Get results in JSON format for scripting:
Command Line Options
Target Specification
--targets, -t <TARGETS>
Comma-separated list of scan targets. Supports:
- Individual IPs:
192.168.1.1 - IP ranges:
192.168.1.1-192.168.1.100 - CIDR blocks:
192.168.1.0/24,10.0.0.0/16
Default: Uses the CIDR block of the selected network interface
Examples:
# Single IP
# Multiple IPs
# IP range
# CIDR block
# Mixed specification
--ports, -p <PORTS>
Comma-separated list of ports and port ranges to scan.
Default: 1-65535 (all ports)
Examples:
# Common ports
# Port ranges
# Mixed specification
Scan Options
--arp-only
Perform only ARP scanning, skipping SYN port scanning.
Use case: Quick device discovery without the time overhead of port scanning.
--vendor
Enable MAC address vendor lookup to identify device manufacturers.
--host-names
Enable reverse DNS lookup to resolve hostnames for discovered devices.
Network Configuration
--interface, -i <INTERFACE>
Select a specific network interface for scanning.
Default: Automatically selects the default network interface
Examples:
# Use specific interface
# List available interfaces (use system tools)
--source-port <SOURCE_PORT>
Set the source port for outgoing scan packets.
Default: Automatically selects an available port
Output Options
--json
Output results in JSON format instead of human-readable tables.
Use case: Programmatic processing, integration with other tools.
--quiet, -q
Suppress progress messages, only show final results.
Use case: Cleaner output for scripting and automation.
Timing and Performance
--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)
# Slower scanning (more thorough)
Debugging
--debug
Enable debug logging for troubleshooting scan operations.
Output Formats
Table Format (Default)
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 |
+---------------+----------+-------------------+------------------------+-------------+
JSON Format
Common Use Cases
Network Discovery
Discover all devices on your local network:
Security Auditing
Comprehensive scan with detailed information:
Service Discovery
Find devices running specific services:
Quick Port Check
Check if specific hosts have certain ports open:
Subnet Scanning
Scan multiple subnets:
Integration and Automation
Bash Scripting
#!/bin/bash
# Perform scan and save results
# Process results with jq
Python Integration
# Run scan
=
# Parse results
=
=
Cron Jobs
# Add to crontab for periodic scanning
# Run every hour and log changes
Troubleshooting
Permission Errors
Error: permission denied: must run with root privileges
Solution: Run with sudo:
Network Interface Issues
Error: cannot find interface
Solutions:
-
List available interfaces:
# Linux # macOS/BSD -
Specify interface explicitly:
No Results Found
Possible causes:
- Firewall blocking scan packets
- Network devices configured to ignore ARP/ICMP
- Incorrect network range specified
Solutions:
-
Increase timeout:
-
Use debug mode:
-
Verify network configuration:
# Check your IP and network
Performance Issues
For large networks:
-
Use ARP-only for initial discovery:
-
Limit port ranges:
-
Scan smaller subnets:
Security and Ethics
Responsible Usage
- Only scan networks you own or have explicit permission to test
- Be aware that network scanning may be logged by security systems
- Some networks may consider scanning as hostile activity
- Consider network impact - scanning can generate significant traffic
Legal Considerations
- Network scanning may be restricted by local laws and regulations
- Corporate networks often have policies against unauthorized scanning
- Always obtain proper authorization before scanning
License
This project is dual-licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT License (LICENSE-MIT or http://opensource.org/licenses/MIT)
at your option.