用iptables开启防火墙报错: Failed to start  IPv4 firewall with iptables.

转载于:https://blog.csdn.net/ls1645/article/details/78750561

错误原因:因为centos7.0默认不是使用iptables方式管理,而是firewalld方式。CentOS6.0防火墙用iptables管理。

解决办法有两个:使用firewalld方式。或者关闭firewalld,然后安装iptables。

一、关闭firewalld,安装iptables过程:

停止并屏蔽firewalld:

  

  systemctl stop firewalld

  systemctl mask firewalld

安装iptables-services:

  

  yum install iptables-services

设置开机启动:

  systemctl enable iptables

停止/启动/重启 防火墙:

systemctl [stop|start|restart] iptables

#or

service iptables [stop|start|restart]

保存防火墙配置:

service iptables save

#or

/usr/libexec/iptables/iptables.init save

按照上述命令配置后的界面:

二、从iptables切换回firewalld

1、先看firewalld的状态:inactive

2、安装firewalld

3、切换到firewalld,切换过程与切换iptables一样

/************下面是iptables的一些命令*******************************/

查询防火墙状态:

[root@localhost ~]# service  iptables status

停止防火墙:

[root@localhost ~]# service  iptables stop

启动防火墙:

[root@localhost ~]# service  iptables start

重启防火墙:

[root@localhost ~]# service  iptables restart

永久关闭防火墙:

[root@localhost ~]# chkconfig  iptables off

永久关闭后启用:

[root@localhost ~]# chkconfig  iptables on

开启端口:

[root@localhost ~]# vim/etc/sysconfig/iptables

/**********下面是firewalld的一些命令*****************************/

#systemctl statusfirewalld  //查看状态,看电脑上是否已经安装firewalld

#yum installfirewalld  //安装firewalld防火墙

#systemctl startfirewalld.service   //开启防火墙

#systemctl stop firewalld.service  //关闭防火墙

#systemctl enable firewalld.service //设置开机自动启动

#systemctl disable firewalld.service  //设置关闭开机制动启动

#firewall-cmd--reload  //在不改变状态的条件下重新加载防火墙

启用某个服务

#firewall-cmd --zone=public --add-service=https  //临时

#firewall-cmd --permanent --zone=public --add-service=https  //永久

开启某个端口

#firewall-cmd--permanent --zone=public --add-port=8080-8081/tcp  //永久

#firewall-cmd  --zone=public --add-port=8080-8081/tcp   //临时

查看开启的端口和服务

#firewall-cmd--permanent --zone=public --list-services   //服务空格隔开 例如 dhcpv6-client https ss

#firewall-cmd--permanent --zone=public --list-ports //端口空格隔开  例如 8080-8081/tcp 8388/tcp 80/tcp

#systemctl restartfirewalld.service  //修改配置后需要重启服务使其生效

#firewall-cmd--zone=public --query-port=8080/tcp //查看服务是否生效(例:添加的端口为8080)

/**********下面是systemctl的一些命令*******************************/

观察iptables和firewalld使用的两组命令,发现三个常用的命令:service、chkconfig、systemctl。那么它们分别是做什么的呢?(去网上搜索了一下给出了答案)

systemctl命令是系统服务管理器指令,它实际上将 service 和 chkconfig 这两个命令组合到一起。

任务

旧指令

新指令

使某服务自动启动

chkconfig --level 3 httpd on

systemctl enable httpd.service

使某服务不自动启动

chkconfig --level 3 httpd off

systemctl disable httpd.service

检查服务状态

service httpd status

systemctl status httpd.service(服务详细信息)

systemctl is-active httpd.service(仅显示是否 Active)

显示所有已启动的服务

chkconfig --list

systemctl list-units --type=service

启动某服务

service httpd start

systemctl start httpd.service

停止某服务

service httpd stop

systemctl stop httpd.service

重启某服务

service httpd restart

systemctl restart httpd.service

总结:

记是记不住的,实操才可以,熟能生巧。

抓住一个问题,深入去挖,往往能挖出一片,从而扫清一片盲点。深挖能出清泉。

参考文章:

https://www.vkilo.com/rhel-7-iptables-service.html

http://blog.csdn.net/Joe68227597/article/details/75207859

http://www.linuxidc.com/Linux/2012-06/63111.html

http://man.linuxde.net/systemctl

CentOS 7 :Failed to start IPv4 firewall with iptables.的更多相关文章

  1. CentOS 7.2:Failed to start IPv4 firewall with iptables

    问题 系统是centos7.2,且已经安装了iptables服务,但是在执行启动命令后,却报了iptables服务无法正常启动的错误. 启动命令如下: systemctl start iptables ...

  2. Centos7启动防火墙时报错Failed to start IPv4 firewall with iptables

    今天在虚拟机的Linux系统(centos7)里安装Redis,准备学习一下布隆过滤器呢,安装完后使用Windows本机访问不了虚拟机里的Redis,telnet不通能够ping通.于是就去看防火墙, ...

  3. 关于centos启动报错:Failed to start Crash recovery kernel arming的解决方案

    在VMware中安装了centos,重启时报错:Failed to start Crash recovery kernel arming 本质是kdump服务启动失败 先来说一下,什么是kdump K ...

  4. 20190603 - CentOS 7 提示 Failed to load SELinux policy. Freezing 导致卡住不启动的解决办法

    现象 最近 Windows 和两台 Mac 混用,将 Windows VirtualBox 中安装的 CentOS 7 拷贝到 Mac 上. 启动 CentOS 7 时,图形界面进度卡在最后,按 Es ...

  5. docker—tomcat 报错:Failed to get D-Bus connection: Operation not permitted

    docker search centos   查系统镜像 docker pull docker.io/centos 进入容器 [root@git opt]# docker images REPOSIT ...

  6. centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not foundc

    现象: 在centOS7中启动MySQL数据库提示: Failed to start mysqld.service: Unit not found [明明已经安装了,为什么提示不存在呢?] 原因: 在 ...

  7. 开发错误记录5:Failed to resolve: com

    今在导入项目时报:Failed to resolve: com.android.support:appcompat-v7:23.1.1包! 一.按F12查看包引用情况 v7包版本不一样,环境中只有co ...

  8. 启动Eclipse弹出:Failed to load JavaHL Library 错误框的解决办法

    一.问题背景描述: eclipse安装完svn插件以后,在启动时出现:Failed to load JavaHL Library.  These are the errors that were en ...

  9. 编译java文件,出错:Failed to establish a connection with the target VM

    helloword程序,所有java学习人员人生第一个程序,哎妈,基础太差,出错 public class Helloword{ public Helloword() { public static ...

随机推荐

  1. Zookeeper安装使用及JavaAPI使用

    一.Zookeeper单击模式安装及使用 1.系统环境 2.导入JDK和Zookeeper包 1).使用SecureCRT工具打开SFTP连接,直接拖拽,到当前用户文件夹下,然后使用mv命令(mv 文 ...

  2. ImageMagick、imagick和ghostscript三者的关联

    http://467754239.blog.51cto.com/4878013/1602518/ 一.功能概述 ImageMagick是第三方的图片处理软件,功能要比GD强大.建议两者都安装,并不冲突 ...

  3. iOS(WKWebView)OC与JS交互 之三

      随着H5功能愈发的强大,没进行过混合开发的小伙们都不好意思说自己能够独立进行iOS的app开发,在iOS7操作系统下,常用的native,js交互框架有easy-js,WebViewJavascr ...

  4. c# 中config.exe 引发的一些问题

    public static void CreateConfig(){ //c#可以添加内置的app.config,我们通过ConfigrationManager类可以 //可以很轻松的操作相关节点,操 ...

  5. SQL Server 2012 R2升级到SQL Server 2016无法正常启动数据库服务解决方案

    原定周末把公司的TFS升级到2018,由于TFS 2018需要SQL Server至少是2016以上版本,所以还需要将原来的SQL Server 2012 R2一并升级.今天早上负责的同事告诉我升级失 ...

  6. Linux下的tr编辑器命令详解

    通过使用 tr,您可以非常容易地实现 sed 的许多最基本功能.您可以将 tr 看作为 sed 的(极其)简化的变体:它可以用一个字符来替换另一个字符,或者可以完全除去一些字符.您也可以用它来除去重复 ...

  7. day_6.10py面试题:访问百度的过程

    DNS : 解析域名 DHCP:一种协议,自动分配ip 发现局域网中没有ip的电脑分配ip 面试题: 访问百度的整个过程 打开浏览器,访问百度的过程: 1.我的电脑确定有无网关,arp得到默认网管ma ...

  8. 设计模式学习--Builder

    What Builder:将一个复杂的对象的构建和表示分离,使得同样的构建过程可以创建不同的表示. Why Builder也是创建型模式的一种,它是一步一步的向导式的创建一个复杂的对象,Builder ...

  9. ABP之事件总线(5)

    前面已经对Castle Windsor的基本使用进行了学习,有了这个基础,接下来我们将把我们的事件总线再次向ABP中定义的事件总线靠近.从源码中可以知道在ABP中定义了Dictionary,存放三种类 ...

  10. Mysql----整理

    --------------------------------------------------数据常库常用操作总结---------------------------------------- ...