这里写的是我个人习惯,包括windows、Linux、FreeBSD三个系统

 

linux,还是用ipset效率高:

ipset destroy badip
ipset create badip hash:net
ipset add badip 88.214.26.0/24
ipset add badip 185.40.13.0/24
ipset add badip 85.93.20.0/24
ipset add badip 112.175.127.0/24
ipset add badip 112.175.124.0/24
ipset add badip 211.44.226.0/24
ipset add badip 120.42.54.0/24
ipset add badip 51.159.30.0/24
ipset add badip 47.74.0.0/16
ipset add badip 47.52.44.0/24
ipset add badip 47.75.248.0/24
ipset add badip 47.245.2.0/24
ipset add badip 47.91.19.0/24
ipset add badip 47.75.188.0/24
ipset add badip 154.209.214.0/24
ipset add badip 45.136.108.0/24
ipset add badip 122.224.64.0/24
ipset add badip 150.129.144.0/24
ipset add badip 88.99.142.0/24
ipset add badip 45.227.255.0/24
ipset add badip 141.98.80.0/24
ipset add badip 92.246.76.0/24
ipset add badip 163.142.51.0/24
iptables -I INPUT -m set --match-set badip src -j DROP

 

Windows,系统自带的防火墙是效率最高的:

新建的时候可以直接指定:
netsh advfirewall firewall add rule name="badip" protocol=any dir=in action=block remoteip=88.214.26.0/24,185.40.13.0/24,85.93.20.0/24

后续增加删除的话需要一次性全部指定:
netsh advfirewall firewall set rule name="badip" new remoteip=88.214.26.0/24,185.40.13.0/24,85.93.20.0/24,112.175.127.0/24,112.175.124.0/24,211.44.226.0/24,120.42.54.0/24,51.159.30.0/24,47.74.0.0/16,47.52.44.0/24,47.75.248.0/24,47.245.2.0/24,47.91.19.0/24,47.75.188.0/24,154.209.214.0/24,45.136.108.0/24,122.224.64.0/24,150.129.144.0/24,88.99.142.0/24,45.227.255.0/24,141.98.80.0/24,92.246.76.0/24,163.142.51.0/24

 

FreeBSD,需要先打开ipfw(我个人喜欢用这个),并且写入规则:

sysrc firewall_enable="YES"
sysrc firewall_type="open"
sysrc firewall_script="/etc/ipfw.rules"
echo '#!/bin/sh' > /etc/ipfw.rules
echo "ipfw -q -f flush" >> /etc/ipfw.rules
echo 'cmd="ipfw -q "' >> /etc/ipfw.rules
echo '$cmd table 1 add 103.87.79.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 112.175.124.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 112.175.127.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 120.42.54.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 122.224.64.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 125.7.248.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 136.243.171.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 141.98.80.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 141.98.81.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 141.98.9.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 144.76.17.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 150.129.144.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 154.209.214.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 163.142.51.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 171.105.47.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 171.107.47.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 185.153.198.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 185.156.177.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 185.209.0.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 185.40.13.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 188.163.170.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 192.184.8.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 193.188.22.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 193.70.81.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 207.148.112.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 209.188.89.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 211.44.226.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 212.90.170.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 219.138.210.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 221.122.78.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 45.136.108.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 45.141.87.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 45.227.255.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.245.2.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.52.44.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.74.0.0/16 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.75.188.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.75.248.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 47.91.19.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 49.72.213.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 5.9.201.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 51.159.30.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 51.89.6.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 85.93.20.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 88.214.26.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 88.99.142.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 91.121.47.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 92.118.37.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 92.246.76.0/24 0' >> /etc/ipfw.rules
echo '$cmd table 1 add 92.63.194.0/24 0' >> /etc/ipfw.rules
echo '$cmd add 00002 deny all from "table(1)" to any' >> /etc/ipfw.rules
echo '$cmd add 65534 allow all from any to any' >> /etc/ipfw.rules

运行时可以添加:

ipfw?-q?table?1?flush
ipfw?-q?table?1?add?103.87.79.0/24?0
ipfw?-q?table?1?add?112.175.124.0/24?0
ipfw?-q?table?1?add?112.175.127.0/24?0
ipfw?-q?table?1?add?120.42.54.0/24?0
ipfw?-q?table?1?add?122.224.64.0/24?0
ipfw?-q?table?1?add?125.7.248.0/24?0
ipfw?-q?table?1?add?136.243.171.0/24?0
ipfw?-q?table?1?add?141.98.80.0/24?0
ipfw?-q?table?1?add?141.98.81.0/24?0
ipfw?-q?table?1?add?141.98.9.0/24?0
ipfw?-q?table?1?add?144.76.17.0/24?0
ipfw?-q?table?1?add?150.129.144.0/24?0
ipfw?-q?table?1?add?154.209.214.0/24?0
ipfw?-q?table?1?add?163.142.51.0/24?0
ipfw?-q?table?1?add?171.105.47.0/24?0
ipfw?-q?table?1?add?171.107.47.0/24?0
ipfw?-q?table?1?add?185.153.198.0/24?0
ipfw?-q?table?1?add?185.156.177.0/24?0
ipfw?-q?table?1?add?185.209.0.0/24?0
ipfw?-q?table?1?add?185.40.13.0/24?0
ipfw?-q?table?1?add?188.163.170.0/24?0
ipfw?-q?table?1?add?192.184.8.0/24?0
ipfw?-q?table?1?add?193.188.22.0/24?0
ipfw?-q?table?1?add?193.70.81.0/24?0
ipfw?-q?table?1?add?207.148.112.0/24?0
ipfw?-q?table?1?add?209.188.89.0/24?0
ipfw?-q?table?1?add?211.44.226.0/24?0
ipfw?-q?table?1?add?212.90.170.0/24?0
ipfw?-q?table?1?add?219.138.210.0/24?0
ipfw?-q?table?1?add?221.122.78.0/24?0
ipfw?-q?table?1?add?45.136.108.0/24?0
ipfw?-q?table?1?add?45.141.87.0/24?0
ipfw?-q?table?1?add?45.227.255.0/24?0
ipfw?-q?table?1?add?47.245.2.0/24?0
ipfw?-q?table?1?add?47.52.44.0/24?0
ipfw?-q?table?1?add?47.74.0.0/16?0
ipfw?-q?table?1?add?47.75.188.0/24?0
ipfw?-q?table?1?add?47.75.248.0/24?0
ipfw?-q?table?1?add?47.91.19.0/24?0
ipfw?-q?table?1?add?49.72.213.0/24?0
ipfw?-q?table?1?add?5.9.201.0/24?0
ipfw?-q?table?1?add?51.159.30.0/24?0
ipfw?-q?table?1?add?51.89.6.0/24?0
ipfw?-q?table?1?add?85.93.20.0/24?0
ipfw?-q?table?1?add?88.214.26.0/24?0
ipfw?-q?table?1?add?88.99.142.0/24?0
ipfw?-q?table?1?add?91.121.47.0/24?0
ipfw?-q?table?1?add?92.118.37.0/24?0
ipfw?-q?table?1?add?92.246.76.0/24?0
ipfw?-q?table?1?add?92.63.194.0/24?0

 

 

 

 

 

作者 听涛

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注