Skip to content

Instantly share code, notes, and snippets.

@vfreex
Created November 20, 2018 09:58
Show Gist options
  • Save vfreex/32b7de2e36422dbee94454afc762305e to your computer and use it in GitHub Desktop.
Save vfreex/32b7de2e36422dbee94454afc762305e to your computer and use it in GitHub Desktop.
Test which TCP ports are blocked by my ISP
#!/bin/bash
for port in {1..9999}; do
echo -n "TCP $port: "
result=$(nc "$1" "$port" -w 1 2>&1 < /dev/null)
if [ "$?" -eq 0 ]; then
echo "Open"
continue
fi
if [[ "$result" == *refused* ]]; then
echo "Closed"
fi
if [[ "$result" == *time* ]]; then
echo "$port" >> block_list.txt
echo "BLOCKED"
fi
done
@bi4nbn
Copy link

bi4nbn commented Jan 30, 2024

冒昧的问一句,这个脚本如何使用?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment