Below script will help you to detect duplicate IP address in a subnet
The key command is the arping command which will send out an ARP packet with DAD (duplicate address detection)
If the return value is zero indicates , everything is good and non-zero return value indicates duplicate IP
---------------------------------------------------------------
#!/bin/bash
DEVICE=eth0 # <-- Your device plugged to netowork
IPADDR="X.X.X.X" # <-- IP address to check for duplicates
if [ ! arping -q -c 2 -w 3 -D -I ${DEVICE} ${IPADDR} ]
then
echo $"Error, some other host already uses address ${IPADDR}."
exit 1
fi
---------------------------------------------------------------