【Centos-Firewall】CentOS7 启动防火墙 报错 Failed to start iptables.service: Unit not found.

原文地址:https://blog.csdn.net/qq_29369653/article/details/86577326

CentOS7中执行

service iptables restart/start/stop

报错:

Redirecting to /bin/systemctl restart iptables.service
Failed to restart iptables.service: Unit not found.

原因是因为CentOS7 里面是用 firewalld (相关介绍介绍请点击)来管理防火墙的

命令语法:firewall-cmd [--zone=zone] 动作 [--permanent] 
注:如果不指定--zone选项,则为当前所在的默认区域,--permanent选项为是否将改动写入到区域配置文件中

firewall的状态:
--state ##查看防火墙的状态
--reload ##重新加载防火墙,中断用户的连接,将临时配置清掉,加载配置文件中的永久配置
--complete-reload ##重新加载防火墙,不中断用户的连接(防火墙出严重故障时使用)
--panic-on ##紧急模式,强制关闭所有网络连接,--panic-off是关闭紧急模式

例:

添加80端口为允许:

firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent  没有此参数重启后失效)

添加范围例外端口 如 5000-10000:

firewall-cmd --zone=public --add-port=5000-10000/tcp --permanent 

添加完成后立刻生效:

重新载入
firewall-cmd --reload
查看
firewall-cmd --zone=public --query-port=80/tcp
删除
firewall-cmd --zone=public --remove-por=80/tcp --permanent

这是我刚学习Linux 在CentOS7下安装tomcat 不能访问默认页面时遇到的问题,记录一下。

参考:

Centos7-----firewalld详解>>>http://blog.51cto.com/11638832/2092203

解决CentOS7关闭/开启防火墙出现Unit iptables.service failed to load: No such file or directory.>>>https://blog.csdn.net/c233728461/article/details/52679558(该链接下还有还原传统防火墙管理方式的方法)
 

发布了28 篇原创文章 · 获赞 3 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/qq_34291570/article/details/105569162