CentOS7中执行

service iptables start/stop

会报错Failed to start iptables.service: Unit iptables.service failed to load: No such file or directory.

在CentOS 7或RHEL 7或Fedora中防火墙由firewalld来管理,

如果要添加范围例外端口 如 1000-2000
语法命令如下:启用区域端口和协议组合
firewall-cmd [--zone=<zone>] --add-port=<port>[-<port>]/<protocol> [--timeout=<seconds>]
此举将启用端口和协议的组合。端口可以是一个单独的端口 <port> 或者是一个端口范围 <port>-<port> 。协议可以是 tcp 或 udp。
实际命令如下:

添加

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

firewall-cmd --zone=public --add-port=1000-2000/tcp --permanent

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

当然你可以还原传统的管理方式。

执行一下命令:

systemctl stop firewalld
systemctl mask firewalld

并且安装iptables-services:

yum install iptables-services

设置开机启动:

systemctl enable iptables
systemctl stop iptables
systemctl start iptables
systemctl restart iptables
systemctl reload iptables

保存设置:

service iptables save

OK,再试一下应该就好使了

开放某个端口 在/etc/sysconfig/iptables里添加

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT

参考https://blog.csdn.net/c233728461/article/details/52679558/

Failed to stop iptables.service: Unit iptables.service not loaded.解决方法的更多相关文章

  1. Failed to stop iptables.service: Unit iptables.service not loaded.

    redhat 7 [root@lk0 ~]# service iptables stop Redirecting to /bin/systemctl stop iptables.service Fai ...

  2. CentOS 7 防火墙 出现Failed to start iptables.service: Unit iptables.service failed to load

    错误信息如下: [root]# service iptables start Redirecting to /bin/systemctl start iptables.service Failed t ...

  3. Failed to issue method call: Unit httpd.service failed to load: No such file or directory.

    centos7修改httpd.service后运行systemctl restart httpd.service提示 Failed to issue method call: Unit httpd.s ...

  4. Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式

    Failed to issue method call: Unit mysql.service failed to load: No such file or directory解决的方式 作者:ch ...

  5. Failed to start metasploit.service: Unit metasploit.service not found的解释

    不多说,直接上干货! root@kali:~# service metasploit start Failed to start metasploit.service: Unit metasploit ...

  6. docker安装完报错:Failed to start docker.service: Unit docker.service is masked

    执行 systemctl start docker 报错 Failed to start docker.service: Unit docker.service is masked. 解决 syste ...

  7. 停止:service jenkins stop,提示:Failed to stop jenkins.service: Unit jenkins.service not loaded.

    uni@uni-virtual-machine:~$ service jenkins stop Failed to stop jenkins.service: Unit jenkins.service ...

  8. Android Studio support 26.0.0-alpha1 Failed to resolve: com.android.support:appcompat-v7:27.+ 报错解决方法

    AS下如何生成自定义的.jks签名文件, 以及如何生成数字签名 链接:http://www.cnblogs.com/smyhvae/p/4456420.html 链接:http://blog.csdn ...

  9. PHP failed to ptrace(PEEKDATA) pid 13659: Input/output error错误解决方法

    PHP failed to ptrace(PEEKDATA) pid 13659: Input/output error错误解决方法 现在改linux内核文件打开限制<pre>ulimit ...

随机推荐

  1. 「BZOJ2153」设计铁路 - 斜率DP

    A省有一条东西向的公路经常堵车,为解决这一问题,省政府对此展开了调查. 调查后得知,这条公路两侧有很多村落,每个村落里都住着很多个信仰c教的教徒,每周日都会开着自家的车沿公路到B地去"膜拜& ...

  2. python3 session cookie

    session是保存在服务器中的,而cookies是保存在客户端中的.服务器通过session id来跟踪客户,而对于客户端而言,session id是保存在cookies中的,所以只要把cookie ...

  3. Windows下使用命令安装Python的scipy库出错的解决

    平时使用Python都是在Sublime下使用,不想使用IDE.使用各种库时安装也就是使用pip安装即可.来说说今天自己遇到的一个问题:使用scipy数学库时,使用命令: pip install sc ...

  4. Android 使alertDialog.builder不会点击外面和按返回键消失

    这个问题之前一直困扰我,我的需求就是点击对话框外面和按返回键对话框不会消失,按返回键还好解决,拦截下返回键就OK了. 但是点击外面不好解决.之前有人说模态对话框,我看了一会,觉得不是我想要的效果.po ...

  5. Pandas 基础(2) - Dataframe 基础

    上一节我们已经对 Dataframe 的概念做了一个简单的介绍, 这一节将具体看下它的一些基本用法: 首先, 准备一个 excel 文件, 大致内容如下, 并保存成 .csv 格式. 然后, 在 ju ...

  6. linux du

    命令参数: -a或-all  显示目录中个别文件的大小. -b或-bytes  显示目录或文件大小时,以byte为单位. -c或--total  除了显示个别目录或文件的大小外,同时也显示所有目录或文 ...

  7. Java中有多个异常, 如何确定捕获顺序(多个catch),先从上到下执行,判断异常的大小,如果包含捕到异常,就进入这个catch,后面的就不再执行

    Java中异常的捕获顺序(多个catch)( Java代码 import java.io.IOException; public class ExceptionTryCatchTest { publi ...

  8. HDUOJ 不容易系列之(4)——考新郎

    题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2049 一开始我的想法就是使用错排公式,先使用全排列从N对中选出M对,然后再使用错排对选出的M对进行错排计 ...

  9. 让browserify接收命令行参数,在打包时parse yml配置文件

    功能需求: 1用browserify把各种js打包成浏览器端的1个bundle.js,含有yml配置文件 约束: 1 yml配置文件不在当前工程里(现在还不知道放哪里,以后也会变),希望在打包时,用命 ...

  10. VC工程编译相关

    ①error C4996: 'sprintf': This function or variable may be unsafe 这不是语法的错误,而是IDE默认禁止这种容易产生漏洞的旧函数,解决的方 ...