netmap
Scans the local network and maintains a persistent device database at ~/.config/netmap/devices.json.
Requirements
- -
nmap must be installed: INLINECODE2 - Script: INLINECODE3
Commands
CODEBLOCK0
Notes
- - MAC addresses and vendor info require running with
sudo (or they appear blank without it) - Deep scan adds port-based device fingerprinting: identifies printers, NAS, SSH servers, Apple devices, etc.
- Device database persists across scans — labels survive rescans
- Subnet is auto-detected from the machine's default interface
- Run
scan --deep first time to populate device types, then scan for fast refreshes
netmap
扫描本地网络,并在 ~/.config/netmap/devices.json 中维护一个持久的设备数据库。
依赖
- - 必须安装 nmap:brew install nmap
- 脚本:scripts/netmap.py
命令
bash
发现网络上的所有设备(快速,约30-60秒)
python3 scripts/netmap.py scan
深度扫描——同时对每个设备进行端口扫描以识别类型(较慢,约2-3分钟)
python3 scripts/netmap.py scan --deep
覆盖子网(默认自动检测)
python3 scripts/netmap.py scan --subnet 10.0.0.0/24
列出所有已知设备
python3 scripts/netmap.py list
python3 scripts/netmap.py list --times # 包含首次/最后出现时间
通过IP、主机名、MAC、厂商或设备类型查找设备
python3 scripts/netmap.py find printer
python3 scripts/netmap.py find 192.168.1.12
python3 scripts/netmap.py find Canon
为设备添加友好名称标签
python3 scripts/netmap.py label 192.168.1.12 Canon Printer
python3 scripts/netmap.py label AA:BB:CC:DD:EE:FF Kevins iPhone
显示最近N分钟内首次出现的设备
python3 scripts/netmap.py new --minutes 30
将设备数据库导出为JSON格式
python3 scripts/netmap.py export
持续监控模式(默认每2分钟扫描一次)
python3 scripts/netmap.py watch
python3 scripts/netmap.py watch --interval 60
说明
- - MAC地址和厂商信息需要以 sudo 权限运行(否则会显示为空)
- 深度扫描会添加基于端口的设备指纹识别:可识别打印机、NAS、SSH服务器、苹果设备等
- 设备数据库在多次扫描间持久保存——标签在重新扫描后仍然保留
- 子网会从机器的默认接口自动检测
- 首次运行 scan --deep 以填充设备类型,之后使用 scan 进行快速刷新