首先启动iptables
systemctl start iptable
将会出现以下异常
Job for iptables.service failed because the control process exited with error code. See "systemctl status iptables.service" and "journalctl -xe" for details.
查看异常
journalctl -xe
出现的信息中标红的为异常
Failed to start IPv4 firewall with iptables.
解决方案
因为centos7默认的防火墙是firewalld防火墙,不是使用iptables,因此需要先关闭firewalld服务,或者干脆使用默认的firewalld防火墙。
因为这次报错的服务器是一台刚刚购买的阿里云服务器,所以在操作上忘记关闭默认防火墙的步骤了才导致浪费了些时间在这件事情上。
关闭firewalld:
systemctl stop firewalld
systemctl mask firewalld
使用iptables服务
vi进入编辑模式
开放端口:
-A INPUT -p tcp --dport 80 -j ACCEPT
保存修改:
service iptables save
重启:
systemctl restart iptables.service