1

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.

1
  • 2
    You can run each pipeline in the background, but you might want to look at using nmap instead.
    – chepner
    Commented Jan 29, 2014 at 17:30

2 Answers 2

2
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
2

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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.