Skip to content

Instantly share code, notes, and snippets.

@pedrompcaetano
Last active August 29, 2015 14:19
Show Gist options
  • Save pedrompcaetano/124303512998a67625f9 to your computer and use it in GitHub Desktop.
Save pedrompcaetano/124303512998a67625f9 to your computer and use it in GitHub Desktop.
replace table contents instead of reloading pf ruleset at each crontab interval
#!/bin/sh
PFDIR=/etc/pf-files
ZONEFILE=blocked_zones
mkdir -p ${PFDIR}
> ${PFDIR}/${ZONEFILE}
for ZONE in cn az by kz kg ru tj tm uz vn
do
ftp -o - http://ipdeny.com/ipblocks/data/countries/${ZONE}.zone >> ${PFDIR}/${ZONEFILE}
#sleep 3 #respect ipdeny policies
done
pfctl -t blocked_zones -T replace `cat ${PFDIR}/${ZONEFILE}`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment