拓十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

Whosthere 快速上手:一条命令扫描局域网并导出 JSON 设备清单

Whosthere 快速上手:一条命令扫描局域网并导出 JSON 设备清单

Whosthere 快速上手:一条命令扫描局域网并导出 JSON 设备清单

【免费下载链接】whosthereLocal Area Network discovery tool with an interactive Terminal User Interface (TUI) written in Go. Discover, explore, and understand your LAN in an intuitive way. Knock Knock.. who's there? 🚪项目地址: https://gitcode.com/gh_mirrors/wh/whosthere

Whosthere 是一款用 Go 编写的局域网发现工具(LAN 扫描器),内置交互式 TUI 终端界面。无需管理员权限,它并发使用 mDNS、SSDP 和 ARP 三种方式探测设备,还能通过 OUI 查询自动补全设备厂商信息。本文带你 3 分钟完成安装,并用一条命令扫描局域网、导出设备 JSON 清单 🚪

安装 Whosthere 局域网扫描器的 3 种方法

方法一:Homebrew(macOS / Linux)

brew install whosthere

方法二:Nix / Arch

# NixOS nix profile install nixpkgs#whosthere # Arch Linux (yay) yay -S whosthere-bin

方法三:从源码构建

git clone https://gitcode.com/gh_mirrors/wh/whosthere cd whosthere make build

构建逻辑很简单,就一条go build命令,见 Makefile。

一条命令扫描整个局域网

装好后,进入 CLI 模式执行单次扫描:

whosthere scan -t 5

参数说明:

  • -t 5(即--timeout=5s):本次扫描的最长等待时间,见 scan.go
  • 不加参数时,mDNS、SSDP、ARP 三种扫描器和子网 Sweeper 全部默认开启

执行时终端会显示 "Scanning network..." 动画,结束后以表格形式列出所有发现的设备(IP、MAC、厂商、设备名)。想看看更多可用参数?运行whosthere --help即可。

导出 JSON 设备清单(重点)

想自动化处理设备信息?加上--json --pretty并重定向到文件:

whosthere scan -t 5 --json --pretty > devices.json

生成的devices.json中每个设备都包含完整字段(序列化逻辑在 device.go):

{ "ip": "192.168.1.23", "mac": "aa:bb:cc:dd:ee:ff", "displayName": "living-room-speaker", "manufacturer": "Apple Inc.", "sources": ["arp-cache", "mdns"], "firstSeen": "2026-10-04T00:00:00Z", "lastSeen": "2026-10-04T00:00:05Z", "extraData": {} }

几个实用字段:

  • manufacturer:通过 MAC 前缀 OUI 查得的设备厂商
  • sources:该设备是由哪些扫描器发现的
  • displayName:来自 mDNS/SSDP 的设备友好名称

有jq的话还能秒查清单:

jq '.[].ip' devices.json # 只列出所有 IP jq '.[] | select(.manufacturer == "Apple Inc.")' devices.json # 筛选苹果设备

快速调整扫描参数

需求命令 / 配置
关闭某个扫描器whosthere scan --mdns=false --ssdp=false
指定扫描的子网配置target_subnets: ["10.0.0.0/24"]
调整扫描超时--timeout=10s

Whosthere 支持命令行参数、环境变量(WHOSTHERE__前缀)、YAML 配置文件三级覆盖,配置文件默认位于~/.config/whosthere/config.yaml,完整示例见 README.md,默认值定义在 config.go。

⚠️ 友情提醒:请只在你有权限的网络(如家庭网络)上使用。

小结

场景命令
交互式探索whosthere
单次扫描whosthere scan -t 5
导出 JSON 清单whosthere scan -t 5 --json --pretty > devices.json

从安装到导出清单只需 3 条命令。想持续监控网络?还可以试试后台守护模式whosthere daemon --port=8080,通过 HTTP API 获取设备数据,把它接入你自己的脚本里吧!

【免费下载链接】whosthereLocal Area Network discovery tool with an interactive Terminal User Interface (TUI) written in Go. Discover, explore, and understand your LAN in an intuitive way. Knock Knock.. who's there? 🚪项目地址: https://gitcode.com/gh_mirrors/wh/whosthere

创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考

返回列表