Network Scanner技能使用说明
2026-03-28
新闻来源:网淘吧
围观:18
电脑广告
手机广告
网络扫描器
使用 nmap 发现和识别本地或远程网络上的设备。收集 IP 地址、主机名(通过反向 DNS)、MAC 地址和供应商识别信息。
安全第一:包含内置保护机制,防止意外扫描公共 IP 范围或不具备适当私有路由的网络——避免收到来自托管服务提供商的滥用报告。
要求
nmap- 网络扫描 (apt install nmap或brew install nmap)dig- DNS 查询(通常已预安装)sudo建议拥有管理员权限以发现 MAC 地址
快速开始
# Auto-detect and scan current network
python3 scripts/scan.py
# Scan a specific CIDR
python3 scripts/scan.py 192.168.1.0/24
# Scan with custom DNS server for reverse lookups
python3 scripts/scan.py 192.168.1.0/24 --dns 192.168.1.1
# Output as JSON
python3 scripts/scan.py --json
配置
在~/.config/network-scanner/networks.json中配置命名网络:
{
"networks": {
"home": {
"cidr": "192.168.1.0/24",
"dns": "192.168.1.1",
"description": "Home Network"
},
"office": {
"cidr": "10.0.0.0/24",
"dns": "10.0.0.1",
"description": "Office Network"
}
},
"blocklist": [
{
"cidr": "10.99.0.0/24",
"reason": "No private route from this host"
}
]
}
然后按名称扫描:
python3 scripts/scan.py home
python3 scripts/scan.py office --json
安全特性
该扫描仪包含多项安全检查,以防止意外滥用:
- 黑名单— 位于
黑名单配置数组中的网络始终被阻止 - 公网IP检查— 扫描公网(非RFC1918)IP范围被阻止
- 路由验证— 对于临时CIDR,验证路由是否使用私有网关
可信网络(在networks.json中配置)会跳过路由验证,因为您已明确批准它们。
# Blocked - public IP range
$ python3 scripts/scan.py 8.8.8.0/24
❌ BLOCKED: Target 8.8.8.0/24 is a PUBLIC IP range
# Blocked - in blocklist
$ python3 scripts/scan.py 10.99.0.0/24
❌ BLOCKED: 10.99.0.0/24 is blocklisted
# Allowed - configured trusted network
$ python3 scripts/scan.py home
✓ Scanning 192.168.1.0/24...
命令
# Create example config
python3 scripts/scan.py --init-config
# List configured networks
python3 scripts/scan.py --list
# Scan without sudo (may miss MAC addresses)
python3 scripts/scan.py home --no-sudo
输出格式
Markdown(默认):
### Home Network
*Last scan: 2026-01-28 00:10*
| IP | Name | MAC | Vendor |
|----|------|-----|--------|
| 192.168.1.1 | router.local | AA:BB:CC:DD:EE:FF | Ubiquiti |
| 192.168.1.100 | nas.local | 11:22:33:44:55:66 | Synology |
*2 devices found*
JSON(--json):
{
"network": "Home Network",
"cidr": "192.168.1.0/24",
"devices": [
{
"ip": "192.168.1.1",
"hostname": "router.local",
"mac": "AA:BB:CC:DD:EE:FF",
"vendor": "Ubiquiti"
}
],
"scanned_at": "2026-01-28T00:10:00",
"device_count": 2
}
使用场景
- 设备清单:跟踪网络上的所有设备
- 安全审计识别未知设备
- 文档记录:生成网络拓扑图用于文档记录
- 自动化:与家庭自动化系统集成以检测设备在线状态
使用技巧
- 使用
sudo以获得准确的MAC地址检测(nmap进行ARP操作需要特权) - 配置本地DNS服务器以获得更佳的主机名解析效果
- 将已配置的网络加入列表,避免每次扫描时重复进行路由验证
- 将无法通过私有方式访问的网络加入阻止列表,以防意外操作
- 扩展
MAC_VENDORS脚本中的信息,以提升设备识别能力
文章底部电脑广告
手机广告位-内容正文底部


微信扫一扫,打赏作者吧~