I am experiencing different results using nmap in different contexts. When I use nmap from the command line such as
nmap -sn 192.168.1.0-255
It takes 10 seconds to scan the network. but when I call my testnet.sh script it hangs for a long time. This is my script
#!/bin/bash
GATE=$(route -n | grep 'UG[ \t]' | awk '{print $2}' )
if [ -z "$GATE" ]
then
echo " NO GATEWAY"
else
IP=168.1.1
set ${IP//./ }
SN="$1.$2.$3.0-255"
nmap -sn $SN
fi
exit
I am calling the above script like
bash testnet.sh
In the script you're calling nmap -sn 168.1.1.0-255
rather than nmap -sn 192.168.1.0-255
. 192.168.* is a private subnet which is understandably quicker to scan than 168.1.1.*, a public IP address range out on the Internet.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.