Skip to content

Instantly share code, notes, and snippets.

@cernoel
Created September 5, 2023 07:08
Show Gist options
  • Save cernoel/dfec18f8dc0127a16f072d5ccc7c83ac to your computer and use it in GitHub Desktop.
Save cernoel/dfec18f8dc0127a16f072d5ccc7c83ac to your computer and use it in GitHub Desktop.
quickly check local hosts
#!/bin/bash
HOST_IF="eth0"
RANGE="24"
if [ "x$1" != "x" ]; then
HOST_IF="$1"
fi
if [ "x$2" != "x" ]; then
RANGE="$2"
fi
IP=$(ip -o -4 addr list $HOST_IF | head -n1 | awk '{print $4}' | cut -d/ -f1)
if [ "x$IP" != "x" ]; then
echo $IP found.
nmap -sP $IP/$RANGE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment