It is often necessary to check a remote device to see if certain ports are open. For a quick & dirty test, use netcat (nc) in Terminal.

If you want to automate things a bit to reduce typing, add the following bash function to your ~/.bashrc file

portscan() {
echo 'Stealthed ports will timeout instead of failing'
read -p 'IP Address: ' ipaddr
read -p 'Port: ' portaddr
nc -zvw 3 "$ipaddr" "$portaddr"

To reload .bashrc after editing it, run:

source ~/.bashrc

Now run:


from Terminal and you will be prompted for an IP Address or hostname along with a port to scan. If you want to scan a range of ports use a hyphen, i.e. 20-80 to scan all ports between 20 and 80.

Leave a Reply

Your email address will not be published.