用 arping 检查局域网 IP 是否被占用
在 ARP 层检测 IP 地址冲突,即使对方防火墙拦了 ping 也能发现。
分配静态 IP 前先运行 sudo arping -D -I eth0 192.168.1.50,如果有主机回应 ARP 探测,说明该 IP 已被占用。
01命令
命令
$ sudo arping -D -I eth0 192.168.1.5002作用说明
ping 命令工作在网络层,很多设备会出于安全考虑屏蔽 ICMP,导致误判'没人用这个 IP'。arping 工作在第二层,直接在局域网里广播'谁持有这个 IP',只要网卡在线就一定会回应。-D 参数启用重复地址检测模式,发现冲突时返回非零退出码,适合写进脚本自动挑一个空闲地址。
03风险
!注意: ARP 包不会跨路由器,arping 只能探测同一局域网内的地址;-D 模式需要 root 权限。
04撤销
✓无需撤销——该命令不会改变持久状态。
05来源
- arping(8) — send ARP REQUEST to a neighbour host依据: Page documents -U/unsolicited ARP mode and duplicate address detection; the string 'conflict' and the '-D' option appear in the man page text, confirming -D (duplicate address detection mode).
- arping(8) — Linux man page (iputils)依据: Man page text contains 'arping' usage with -I to select the interface and describes unsolicited ARP mode; confirms arping sends ARP REQUEST at layer 2.
最后验证: 2026-09-19 · 分类: 网络