1.解决firewalld
[root@localhost mysql]# systemctl stop firewalld.service;
[root@localhost mysql]# systemctl disable firewalld.service;
Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
[root@localhost mysql]# systemctl mask firewalld.service;
Created symlink /etc/systemd/system/firewalld.service → /dev/null.
2.安装iptables-services
注检查yum的更新:yum check update
yum -y install iptables-services
//配置date文件
[root@localhost ~]# systemctl enable iptables;
Created symlink /etc/systemd/system/basic.target.wants/iptables.service → /usr/lib/systemd/system/iptables.service.
//启动服务
[root@localhost ~]# systemctl start iptables;
3.开放端口
[root@localhost ~]# vim /etc/sysconfig/iptables
========================================================================
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8090 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 443 -j ACCEPT
其中443就是开放的端口
4.重启服务
[root@localhost ~]# systemctl restart iptables.service
[root@localhost ~]# systemctl enable iptables.service