Skip to content

Instantly share code, notes, and snippets.

@m0rb
Last active September 5, 2021 21:00
Show Gist options
  • Save m0rb/8e8dd731802f54b99eea044a105903ec to your computer and use it in GitHub Desktop.
Save m0rb/8e8dd731802f54b99eea044a105903ec to your computer and use it in GitHub Desktop.
#!/bin/sh
# countryblock.sh -- yet another country blackholing script by morb
# psst, hey kid! wanna blackhole countries with the flick of a wrist?
CC=$1;[ -z $CC ]&&printf "Usage: $0 <country code>\nex:\n$0 cn #China\n"&&exit 1
[ "$USER" != "root" ]&&printf "root required.\n"&&exit 1
ZONE="http://www.ipdeny.com/ipblocks/data/countries/${CC}.zone"
curl -s $ZONE | xargs -I, ip route add blackhole , metric 999
@thedunston
Copy link

That would work too, but there are some county codes (14) in the zone.tab that are not on the ipblocks website.

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