Rat's

CentOS 7使用iptables开放设置端口
说明:CentOS 7默认使用的是firewall作为防火墙,使用iptables必须重新安装设置一下。如果不想太...
扫描右侧二维码阅读全文
05
2017/07

CentOS 7使用iptables开放设置端口

说明:CentOS 7默认使用的是firewall作为防火墙,使用iptables必须重新安装设置一下。如果不想太麻烦可参考:CentOS 7开放设置端口及firewall常用命令介绍
1、直接关闭防火墙

systemctl stop firewalld.service           #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

2、安装并设置iptables service

yum -y install iptables-services

如果要修改防火墙配置,如增加防火墙端口3306

vi /etc/sysconfig/iptables

增加规则

-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后

systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service  #设置防火墙开机启动

最后重启系统使设置生效即可。

更多有关iptables使用请看:Linux防火墙iptables基本应用

Vultr新用户注册送100美元/16个机房按小时计费,支持支付宝,【点击查看】。
最后修改:2017 年 07 月 05 日 02 : 07 PM

发表评论