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
speed up function in bash so it will finish scan in 10 times faster
質問
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.
解決
他のヒント
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.
所属していません StackOverflow