diff --git a/nmip.sh b/nmip.sh index 82195ba..5573d12 100755 --- a/nmip.sh +++ b/nmip.sh @@ -1,6 +1,6 @@ #!/bin/bash -lanip=$(ifconfig | sed -En 's/127.0.0.1//;s/.*inet (addr:)?(([0-9]*\.){3}[0-9]*).*/\2/p') +lanip=$(ip -4 route get 1.1.1.1 2>/dev/null | awk '{for (i = 1; i < NF; i++) if ($i == "src") {print $(i + 1); exit}}') # Colors RED='\033[0;31m' @@ -20,9 +20,9 @@ NC='\033[0m' # No Color if [ ! -f /usr/bin/nmap ];then printf "${LRED} Nmap is not installed...${NC}\n" elif [ ! -z "${1}" ];then - nmap -sP "${1}/24" + nmap -sn "${1}/24" else printf "${LGREEN}Looking up ${lanip}...${NC}\n" - nmap -sP ${lanip}/24 # Use sudo to get names of devies + nmap -sn ${lanip}/24 # Use sudo to get names of devies fi