Created
April 30, 2020 20:11
-
-
Save jgavinray/936882a9199e9e6aab769309cb2c68b9 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ sudo mkdir /etc/pf-files | |
In /etc/pf.conf the following needs to be added: | |
1. In the prerequisites-section add: | |
table <blocked_zones> persist file "/etc/pf-files/blocked_zones" | |
2. In the block-section add early: | |
block in quick proto tcp from <blocked_zones> to any port { 22 80 } | |
blocn_traffic.sh | |
#! /bin/sh | |
# Purpose: Block all traffic from specific countries. Use ISO code. # | |
PF_DIR=/etc/pf-files | |
ZONE_FILE=blocked_zones | |
touch ${ZONE_FILE} | |
for i in cn az by kz kg ru tj tm uz vn kr se th | |
do | |
wget -4 --no-proxy --no-cookies --no-cache \ | |
http://ipdeny.com/ipblocks/data/countries/$i.zone | |
cat $i.zone >> ${ZONE_FILE} | |
sleep 2 | |
done | |
# | |
rm *.zone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment