本文是通过ipset命令配合iptables规则对大量非法ip进行屏蔽。
1.安装ipset命令
1 | #安装ipset |
2. ipset命令相关应用
1 |
|
3. 配置iptables规则
1 | #iptables执行规则 |
4. 实例
a. 清空需要配置的规则名称
1 | [root@localhost ~]# ipset destroy banthis |
b. 编辑配置文件
1 | [root@localhost ~]#vim banthis.txt |
c.导入配置文件
1 | [root@localhost ~]#ipset restore -f banthis.txt |
d.加入iptables配置规则
1 | [root@localhost ~]#iptables -I INPUT -m set --match-set banthis src -p tcp --destination-port 80 -j DROP |
e. 删除规则
1 | [root@localhost ~]#iptables -D INPUT 1 |