Test if a gateway is blocked by the great firewall
Here is a little script that will test if an IP address is currently being blocked by the great firewall of china. I figure it could be adapted for nagios, to let us know when a vpn gateway starts to get blocked.
#!/bin/sh # # A script to test if an IP address is being blocked by the great firewall of china. # # Before you run this script, you must test the IP with https://greatfire.org # in order to register it in their tracker (otherwise the result will be UNKNOWN). # # This script is, of course, entirely unsafe to run with anything but trusted input. # ADDRESS=$1 if [ "$ADDRESS" = "" ]; then echo "USAGE: $0 IP_ADDRESS" echo " where IP_ADDRESS is the IP you want to test to see if it is blocked" exit 3 fi URL="https://d3s2tsdr8lh01d.cloudfront.net/?location=http%3A%2F%2F${ADDRESS}&type=gf_this_site&language=en-US&v=3" result=`curl -s "$URL"` if `echo "$result" | grep -q gf-bg-success`; then echo "NOT BLOCKED" exit 0 fi if `echo "$result" | grep -q gf-bg-blocked`; then echo "BLOCKED" exit 1 fi echo "UNKNOWN" exit 2
(from redmine: created on 2014-10-01)