收藏文章 楼主

linux-centos 服务器禁止 IP 访问/ IP 黑名单

版块:linux   类型:普通   作者:小绿叶技术博客   查看:2119   回复:0   获赞:0   时间:2020-01-31 09:45:18

iftop # 查看带宽,网速监控,流量监控

systemctl stop firewalld 

systemctl mask firewalld # 1.停止 和 注销 systemctl 防火墙


yum install iptables-services # 2.安装 iptables 防火墙


systemctl enable iptables # 3.设置开机自启

 

service iptables [save|stop|start|restart]

# 4.基本使用:

# []里分别对应保存,停止,启动和重启

 

iptables -I INPUT -s 42.118.6.207 -j DROP

# 二、屏蔽 IP

# 1.屏蔽 42.118.6.207

service iptables save

service iptables restart # 2.保存并重启

 


iptables -I INPUT -p tcp --dport 80 -j ACCEPT

iptables -I INPUT -p tcp --dport 443 -j ACCEPT

iptables -I INPUT -p tcp --dport 22 -j ACCEPT

# 三、开启端口

# 因为我们防火墙刚开,默认端口都是屏蔽的,会发现网站访问不了

# 1.我们需要放行端口,这里先放行 80 、 443 和 22 端口


service iptables save

service iptables restart # 2.保存并重启

 

# 然后发现网站访问超快了,那个 IP 的流量消耗也下来了,问题解决


相关链接:

centos 7 添加 ip 黑/白名单

centos 6/7 防火墙开放端口

linux 禁止/开启 ping linux 服务器 ping 设置

linux ping报错Name or service not known

用 shell 脚本修改网卡

修改网卡名-shell


提供企业建站服务,免费网防系统,提交信息登录 http://yundun.ddoss.cn 邮箱: proposal@ddoss.cn 
回复列表
默认   热门   正序   倒序

回复:linux-centos 服务器禁止 IP 访问/ IP 黑名单

头像

用户名:

粉丝数:

签名:

资料 关注 好友 消息