Skip to content

Instantly share code, notes, and snippets.

@branning
Created August 29, 2016 00:19
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 branning/7cc05201a33aceb2c590816ead6f0322 to your computer and use it in GitHub Desktop.
Save branning/7cc05201a33aceb2c590816ead6f0322 to your computer and use it in GitHub Desktop.
Find live hosts on local network with nmap
#!/bin/bash
#
# Find live hosts on local network with nmap
quiet() { $@ >/dev/null 2>&1; }
error() { echo 2>&1 "$@"; }
if ! quiet command -v nmap
then
error "You must install nmap."
case $OSTYPE in
darwin*) error 'Maybe try `brew install nmap`';;
linux*) error 'Maybe try `apt-get install nmap`';;
esac
fi
base_ip=${1-192.168.2.1}
nmap -sP ${base_ip}/24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment