Checking for open ports in Linux

I needed to check if communication over certain ports are open from one IP address to another IP address. The command below will check for open ports between 389 through 499

for PORT in {389..499}; do
  timeout 1 bash -c "</dev/tcp/$PORT &>/dev/null" &&  echo "port $PORT is open"

Leave a Reply

Your email address will not be published. Required fields are marked *