Introduction
Port scanning helps you find open doors (ports) on a computer. This shows which services are ready to talk.
Port scanning helps you find open doors (ports) on a computer. This shows which services are ready to talk.
for port in {start_port..end_port}; do nc -zv target_ip $port sleep 0.1 done
nc is a tool called Netcat used to check ports.
-z means scan without sending data, -v means verbose (show details).
nc -zv 192.168.1.10 80
for port in {20..25}; do nc -zv 192.168.1.10 $port; done
nc -zv google.com 443This script scans ports 80, 81, and 82 on your own computer. It shows only open ports.
#!/bin/bash # Simple port scanner for ports 80 to 82 on localhost for port in {80..82}; do nc -zv 127.0.0.1 $port 2>&1 | grep -E 'succeeded|open' done
Some ports may be filtered by firewalls and show no response.
Running port scans on computers you don't own may be illegal or unwanted.
Netcat must be installed on your system to use nc.
Port scanning finds open network ports on a computer.
Use nc -zv to check if a port is open.
Scan a range of ports with a simple loop in bash.
for port in 22 80; do nc -zv localhost $port done
for port in {20..25} do
nc -zv 127.0.0.1 $port
donePass the test and this pattern moves unknown