Created
December 4, 2017 15:23
-
-
Save asid21/6f09132b1534c0f0052676768f2c4095 to your computer and use it in GitHub Desktop.
ARP Checker
This file contains hidden or 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
| #!/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