From 5967b0e77cfdb8ce39dfa2b14c9fb46c8980d0a5 Mon Sep 17 00:00:00 2001 From: fossilfranv Date: Fri, 22 Jan 2021 09:48:26 -0800 Subject: [PATCH] first commit --- set_ip_blacklist.sh | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 set_ip_blacklist.sh diff --git a/set_ip_blacklist.sh b/set_ip_blacklist.sh new file mode 100644 index 0000000..608c237 --- /dev/null +++ b/set_ip_blacklist.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +rm /tmp/testlog.txt +exec >/tmp/testlog.txt 2>&1 +set -x + +/sbin/ipset -q flush ipsum +/sbin/ipset -q create ipsum hash:net +/bin/bash -c 'for ip in $(/usr/bin/curl --compressed https://raw.githubusercontent.com/stamparm/ipsum/master/ipsum.txt 2>/dev/null | grep -v "#" | grep -v -E "\s[1-2]$" | cut -f 1); do /sbin/ipset add ipsum $ip; done' +/sbin/iptables -I INPUT -m set --match-set ipsum src -j DROP +rm firehol_level3.netset +wget https://iplists.firehol.org/files/firehol_level3.netset +my_file=$(cat firehol_level3.netset |grep -v "#") +/sbin/ipset -q flush fireh +/sbin/ipset -q create fireh hash:net +for row_data in $my_file; do /sbin/ipset add fireh ${row_data}; done +/sbin/iptables -I INPUT -m set --match-set fireh src -j DROP +/sbin/ipset -q flush blockde +/sbin/ipset -q create blockde hash:net +rm blocklist.de +wget -O blocklist.de http://lists.blocklist.de/lists/all.txt +my_file=$(awk 'length($1) < 16 { print $1 }' blocklist.de) +for row_data in $my_file; do /sbin/ipset add blockde ${row_data}; done +/sbin/iptables -I INPUT -m set --match-set blockde src -j DROP +/sbin/ipset -q flush blockde6 +/sbin/ipset -q create blockde6 hash:net family inet6 +my_file=$(awk 'length($1) > 16 { print $1 }' blocklist.de) +echo setting ipv6... +for row_data in $my_file; do /sbin/ipset add blockde6 ${row_data}; done +/sbin/ip6tables -I INPUT -m set --match-set blockde6 src -j DROP \ No newline at end of file