-->
当前位置:首页 > DayDayUp > 正文内容

Centos 7 禁用firewalld改用iptables

Luz2年前 (2022-08-04)DayDayUp3102

firewalld莫名奇妙失效了,端口禁用了外网还是通的,换用iptables

操作

systemctl stop firewalld
systemctl disable firewalld
yum -y install iptables-services  #安装iptables


iptables -I INPUT -p tcp --dport 3306 -j DROP  #屏蔽MySQL端口
iptables -I INPUT -s 192.168.111.111 -p tcp --dport 3306 -j ACCEPT   #对指定ip放通
iptables -I INPUT -i lo -p tcp --dport 3306 -j ACCEPT  #对local放通


测试

在未授权ip上访问不通

image.png

在授权过的ip上正常

image.png



发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。