Skip to content

Instantly share code, notes, and snippets.

@gadelkareem
Last active June 11, 2019 14:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gadelkareem/fe552d70f9d58634a40f7a959700edbd to your computer and use it in GitHub Desktop.
Save gadelkareem/fe552d70f9d58634a40f7a959700edbd to your computer and use it in GitHub Desktop.
#!/usr/bin/env bash
set -euo pipefail
# lock it
PIDFILE="/tmp/$(basename "${BASH_SOURCE[0]%.*}.pid")"
exec 200>${PIDFILE}
flock -n 200 || ( echo "${BASH_SOURCE[0]} script is already running. Aborting . ." && exit 1 )
PID=$$
echo ${PID} 1>&200
cd "$(dirname $(readlink -f "${BASH_SOURCE[0]}"))"
CUR_DIR="$(pwd)"
wget https://www.cloudflare.com/ips-v4 -O ips-v4
wget https://www.cloudflare.com/ips-v6 -O ips-v6
for cfip in `cat ips-v4`; do /usr/sbin/ufw allow from $cfip to any port 80,443 proto tcp comment "cloudflare"; done
for cfip in `cat ips-v6`; do /usr/sbin/ufw allow from $cfip to any port 80,443 proto tcp comment "cloudflare"; done
/usr/sbin/ufw reload > /dev/null
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment