Created
June 21, 2015 19:46
-
-
Save msgodf/05ff9f00b96bc2ff1b58 to your computer and use it in GitHub Desktop.
Get host names of any machines connected to my local network
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
#!/bin/bash | |
for i in $(seq 255); | |
do | |
nslookup 192.168.1.$(echo $i) 192.168.1.1 >/dev/null; | |
if [ $? -ne 1 ]; | |
then | |
echo -n 192.168.1.$i; | |
nslookup 192.168.1.$(echo $i) 192.168.1.1|grep name|cut -d= -f2; | |
fi; | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment