Domanda

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
È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top