Skip to content

Instantly share code, notes, and snippets.

@stojg
Created May 2, 2015 22:55
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 8 You must be signed in to fork a gist
  • Save stojg/70a15a84900da72ff2b5 to your computer and use it in GitHub Desktop.
Save stojg/70a15a84900da72ff2b5 to your computer and use it in GitHub Desktop.
port-check.sh - small script to check if TCP ports are opened through firewalls etc.
#!/bin/bash
function checkport {
if nc -zv -w30 $1 $2 <<< '' &> /dev/null
then
echo "[+] Port $1/$2 is open"
else
echo "[-] Port $1/$2 is closed"
fi
}
# Example checks
checkport 'ad.server.one' 389
checkport 'ad.server.one' 636
checkport 'webserver.server.two' 443
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment