From 4c10b9e110ab9e588e845fb42c960464e43bacb8 Mon Sep 17 00:00:00 2001 From: Mollusk Date: Thu, 29 Oct 2026 14:59:00 -0400 Subject: [PATCH] nmip.sh: find LAN IP with ip instead of ifconfig Co-Authored-By: Claude Opus 5.5 --- nmip.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) 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