1:检查是否安装iptables防火墙:
[root@localhost bin]# service iptables status
Redirecting to /bin/systemctl status iptables.service
iptables.service
Loaded: not-found (Reason: No such file or directory)
Active: inactive (dead)
2:没有安装的话默认使用的是firewall作为防火墙,所以把他停掉,安装一个iptables
[root@localhost sysconfig]# systemctl stop firewalld
[root@localhost sysconfig]# systemctl mask firewalld
ln -s '/dev/null' '/etc/systemd/system/firewalld.service'
[root@localhost sysconfig]# yum install -y iptables (安装iptables)
已加载插件:fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.163.com
* extras: mirrors.cn99.com
* updates: mirrors.njupt.edu.cn
正在解决依赖关系
--> 正在检查事务
---> 软件包 iptables.x86_64.0.1.4.21-13.el7 将被 升级
---> 软件包 iptables.x86_64.0.1.4.21-24.1.el7_5 将被 更新
[root@localhost sysconfig]# systemctl start iptables.service
[root@localhost sysconfig]# systemctl enable iptables.service //设置开机自启
ln -s '/usr/lib/systemd/system/iptables.service' '/etc/systemd/system/basic.target.wants/iptables.service'
[root@localhost sysconfig]# service iptables status //状态
Redirecting to /bin/systemctl status iptables.service
iptables.service - IPv4 firewall with iptables
Loaded: loaded (/usr/lib/systemd/system/iptables.service; enabled)
Active: active (exited) since 四 2018-07-12 23:58:08 CST; 47s ago
Main PID: 17625 (code=exited, status=0/SUCCESS)
[root@localhost sysconfig]# vi /etc/sysconfig/iptables //添加开放端口