Skip to content

Instantly share code, notes, and snippets.

@asid21
Created December 4, 2017 15:23
Show Gist options
  • Select an option

  • Save asid21/6f09132b1534c0f0052676768f2c4095 to your computer and use it in GitHub Desktop.

Select an option

Save asid21/6f09132b1534c0f0052676768f2c4095 to your computer and use it in GitHub Desktop.
ARP Checker
#!/bin/bash
function usage() {
echo 'Usage: '$0' [-a] [update]'
echo ' -a Print arp table'
echo ' update Update arp table'
exit 1
}
if [ $# -lt 1 ]; then
usage
elif [ $1 == "update" ]; then
base=$(ifconfig | sed 's/[: ]/\n/g' | grep -e '[0-9]*\.[0-9]*\.[0-9]*\.[0-9]*' | grep -ve '255' -ve '127' | sed 's/^\([0-9]*\.[0-9]*\.[0-9]*\)\.[0-9]*$/\1/g')
for i in `seq 0 255`; do
ping -w 1 -c 1 $base.$i >/dev/null 2>&1 &
done
elif [ $1 == "-a" ]; then
cat /proc/net/arp | awk 'NR!=1{printf("%s %s\n",$1,$4);}' | grep -v '00:00:00:00:00:00'
else
usage
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment