mapcidr is a CIDR processing tool produced by ProjectDiscovery. Core advantages:Expand/aggregate/slice/shuffle + IPv4/IPv6 dual stack + Pipeline-friendly。
Project address:https://github.com/projectdiscovery/mapcidr
Basic operations
# CIDR 展开为 IP 列表
echo 192.168.1.0/24 | mapcidr
# 统计 IP 数量
echo 10.0.0.0/16 | mapcidr -count
# IP 列表聚合为 CIDR
cat ips.txt | mapcidr -aggregate
Shuffle IP order (to avoid sequential scanning triggering alerts)
echo 192.168.1.0/24 | mapcidr -si
Skip base and broadcast addressesecho 192.168.1.0/24 | mapcidr -skip-base -skip-broadcast
## 网段切片
```bash
# 按主机数切片(每片 256 个 IP)
echo 10.0.0.0/16 | mapcidr -sbh 256
# 按 CIDR 大小切片(切成 /24)
echo 10.0.0.0/16 | mapcidr -sbc 24
# 切片后分发扫描
echo 10.0.0.0/16 | mapcidr -sbc 24 | \
while read cidr; do naabu -host "$cidr" -p 80,443 -silent; done
Pipeline integration
# CIDR 展开 → 端口扫描
echo 10.0.0.0/24 | mapcidr -si | naabu -p 80,443 -silent
# IP 去重聚合
cat scan_results.txt | mapcidr -aggregate
# 过滤 IP 范围
echo 10.0.0.0/8 | mapcidr -fi 10.0.1.0/24