Skip to content

Instantly share code, notes, and snippets.

@msgodf
Created June 21, 2015 19:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msgodf/05ff9f00b96bc2ff1b58 to your computer and use it in GitHub Desktop.
Save msgodf/05ff9f00b96bc2ff1b58 to your computer and use it in GitHub Desktop.
Get host names of any machines connected to my local network
#!/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