Skip to content

Instantly share code, notes, and snippets.

@mombrea
Created December 26, 2013 16:51
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save mombrea/8135924 to your computer and use it in GitHub Desktop.
Save mombrea/8135924 to your computer and use it in GitHub Desktop.
Block a list of IP ranges using IPSet and IPTables
#!/bin/bash
#Script to process ip ranges to ban using IPSet and IPTables
ipset create countryblock hash:net
while read line; do ipset add countryblock $line; done < blocklist.txt
iptables -I INPUT -m set --match-set countryblock src -j DROP
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment