Question

i use below function to scan if in my network port 80 is open or not,

in case if port is closed, it wait for 1sec, how can i seed it up?

so the same function will can run 10 times in the same time or something like?

while read ip
do
    nc -zw1 $ip 80 && echo "$ip" >> opened || echo "$ip" >> closed;
done < list

or maybe an alternative what will do the same more fast,

Thank you.

Was it helpful?

Solution

while read ip
do
    (nc -zw1 $ip 80 && echo "$ip" >> opened || echo "$ip" >> closed) & # The & will run each test in the background, allowing all tests to be done more or less concurrently.
done < list

OTHER TIPS

Use a network scanner like nmap:

sudo nmap -iL list -Pn -p 80

nmap will scan multiple hosts in parallel and can do SYN scans rather than regular connection attempts, making it two orders of magnitude faster.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top