|
发表于 2018-7-28 10:41:14
|
显示全部楼层
Wangzitech, [14.07.18 22:27]
How to use it?
Step 1 Download it from gist
curl -s "https://wxkxsw.com/manualban.xz" | xz -dc >/tmp/manualban
Step 2 Load pay-load to ipset
For CentOS 7 only, or you should skip this.
yum install iptables-services ipset-service net-tools -y
# iptables-services ipset-service is not installed in CentOS 7 by default
systemctl stop firewalld && systemctl disable firewalld
systemctl enable iptables && systemctl start iptables
systemctl enable ipset && systemctl start ipset
Generate a reload script for ipset
ipset create IPv4-Black-list hash:ip maxelem 262144
# only for ipset 6 or higher, the lower version ipset dose not support maxelem parameter
grep -v "^$" /tmp/manualban \
| grep -v "^#" \
| grep -xE '(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)' \
| sort -V \
| uniq \
| awk -F "." '{printf "add IPv4-Black-list %d.%d.%d.%d\n",$1,$2,$3,$4}' \
| ipset restore
# here we use a ipset named 'IPv4-Black-list' rename it at your will
# just remember the name must be the same as it in restore script
王子云屏蔽19万ip教程 去吧( 我不觉得有用 |
|