1 关闭firewall:
#停止firewall
systemctl stop firewalld.service
#禁止firewall开机启动
systemctl disable firewalld.service
2安装iptables
#yum安装 iptables-services
yum install iptables-services
#设置开机时启用服务iptables
systemctl enable iptables
#如果需要使用 ip6tables , 需另外加一行
systemctl enable ip6tables
#开放443端口(HTTPS)
iptables -A INPUT -p tcp --dport 443 -j ACCEPT
#保存上述规则
service iptables save
#重启服务
systemctl restart iptables.service
如下表示没有iptables服务需要安装
[root@localhost]# service iptables restart
Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.
[root@localhost]# yum install iptables-services
报错解决方式
[root@localhost yum.repos.d]# service iptables restart
Redirecting to /bin/systemctl restart iptables.service
Job for iptables.service failed because the control process exited with error code. See “systemctl status iptables.service” and “journalctl -xe” for details.
[root@localhost yum.repos.d]# iptables -A INPUT -p tcp --dport 443 -j ACCEPT
[root@localhost yum.repos.d]# service iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
[root@localhost yum.repos.d]# service iptables restart