Created
August 11, 2011 09:12
-
-
Save lancelakey/1139218 to your computer and use it in GitHub Desktop.
Detect or Find Duplicate IP Addresses
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script was written for and works on Mac OS X | |
# I have to use sudo to run arping on Mac OS X | |
# I believe the options for arping on linux are a little different. I believe you use -D for duplicate IP detection instead of -d but that's from memory and you should check. | |
echo "Starting duplicate IP detection with sudo arping!" | |
for i in {1..254}; | |
do | |
sudo arping -q -d -c 2 192.168.1.$i; [ $? -ne 0 ] && echo "192.168.1.$i duplicate"; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
nice @lancelakey! only an idea:
if ! sudo arping -q -d -c 2 192.168.1.$i ; then
echo 192.168.1.$i duplicate
fi
may be more readable than the one liner capturing exit status of the exit status. ifs containing commands still operate on true or false.
Also, maybe do $? -eq 1 or whatever the proper exit code is. I'm just thinking command not found is 127 but would print duplicate.
just ideas.