linux 封禁ip

鲍成龙 350 0

linux 封禁ip

可以直接服务配置nginx.conf

添加 deny+IP 例如:

封禁单个IP

deny 106.5.76.83;

#封整个段即从123.0.0.1到123.255.255.254的命令
deny 123.0.0.0/8
#封IP段即从123.45.0.1到123.45.255.254的命令
deny 124.45.0.0/16
#封IP段即从123.45.6.1到123.45.6.254的命令是
deny 123.45.6.0/24

重启nginx 服务  ./nginx -s reload

也可以 在tcpd服务器配置中封禁

/etc/hosts.deny

封禁单个IP

ALL: 106.5.76.83;

#封整个段即从123.0.0.1到123.255.255.254的命令

ALL: 123.0.0.0/8

#封IP段即从123.45.0.1到123.45.255.254的命令

ALL: 124.45.0.0/16

#封IP段即从123.45.6.1到123.45.6.254的命令是

ALL: 123.45.6.0/24

 重启服务 service xinetd restart

在防火墙禁止ip访问也是可行的:

封禁IP:

#iptables -I INPUT -s ***.***.***.*** -j DROP

解封IP:

#iptables -D INPUT -s ***.***.***.*** -j DROP

封禁IP段:

#iptables -I INPUT -s ***.***.***.0/24 -j DROP

添加完规则记得保存规则

#/etc/rc.d/init.d/iptables save

查看规则

#iptables -L

重启iptables

#service iptables restart

即可生效

 

发表评论 取消回复
表情 图片 链接 代码

分享