CentOS 7 :Failed to start IPv4 firewall with iptables.

2024-08-25 13:18

本文主要是介绍CentOS 7 :Failed to start IPv4 firewall with iptables.,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

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

    错误原因:因为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]


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

二、从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.htm

http://man.linuxde.net/systemctl


这篇关于CentOS 7 :Failed to start IPv4 firewall with iptables.的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/1105656

相关文章

CentOS 7部署主域名服务器 DNS的方法

《CentOS7部署主域名服务器DNS的方法》文章详细介绍了在CentOS7上部署主域名服务器DNS的步骤,包括安装BIND服务、配置DNS服务、添加域名区域、创建区域文件、配置反向解析、检查配置... 目录1. 安装 BIND 服务和工具2.  配置 BIND 服务3 . 添加你的域名区域配置4.创建区域

Centos环境下Tomcat虚拟主机配置详细教程

《Centos环境下Tomcat虚拟主机配置详细教程》这篇文章主要讲的是在CentOS系统上,如何一步步配置Tomcat的虚拟主机,内容很简单,从目录准备到配置文件修改,再到重启和测试,手把手带你搞定... 目录1. 准备虚拟主机的目录和内容创建目录添加测试文件2. 修改 Tomcat 的 server.X

CentOS系统Maven安装教程分享

《CentOS系统Maven安装教程分享》本文介绍了如何在CentOS系统中安装Maven,并提供了一个简单的实际应用案例,安装Maven需要先安装Java和设置环境变量,Maven可以自动管理项目的... 目录准备工作下载并安装Maven常见问题及解决方法实际应用案例总结Maven是一个流行的项目管理工具

CentOS系统使用yum命令报错问题及解决

《CentOS系统使用yum命令报错问题及解决》文章主要讲述了在CentOS系统中使用yum命令时遇到的错误,并提供了个人解决方法,希望对大家有所帮助,并鼓励大家支持脚本之家... 目录Centos系统使用yum命令报错找到文件替换源文件为总结CentOS系统使用yum命令报错http://www.cppc

GNSS CTS GNSS Start and Location Flow of Android15

目录 1. 本文概述2.CTS 测试3.Gnss Flow3.1 Gnss Start Flow3.2 Gnss Location Output Flow 1. 本文概述 本来是为了做Android 14 Gnss CTS 的相关环境的搭建和测试,然后在测试中遇到了一些问题,去寻找CTS源码(/cts/tests/tests/location/src/android/locat

Oracle Start With关键字

Oracle Start With关键字 前言 旨在记录一些Oracle使用中遇到的各种各样的问题. 同时希望能帮到和我遇到同样问题的人. Start With (树查询) 问题描述: 在数据库中, 有一种比较常见得 设计模式, 层级结构 设计模式, 具体到 Oracle table中, 字段特点如下: ID, DSC, PID; 三个字段, 分别表示 当前标识的 ID(主键), DSC 当

centos 6安装 vim

centos 安装vim 1.首先查询当前当前vim所依赖的包存在不存在.检查缺少哪个几个依赖包 [root@bogon firstCopy]# rpm -qa|grep vivimvim-common-7.4.160-5.el7.x86_64vim-enhanced-7.4.160-5.el7.x86_64vim-filesystem-7.4.160-5.el7.x86_64vim-

NGINX轻松管理10万长连接 --- 基于2GB内存的CentOS 6.5 x86-64

转自:http://blog.chinaunix.net/xmlrpc.php?r=blog/article&uid=190176&id=4234854 一 前言 当管理大量连接时,特别是只有少量活跃连接,NGINX有比较好的CPU和RAM利用率,如今是多终端保持在线的时代,更能让NGINX发挥这个优点。本文做一个简单测试,NGINX在一个普通PC虚拟机上维护100k的HTTP

笔记整理—内核!启动!—kernel部分(2)从汇编阶段到start_kernel

kernel起始与ENTRY(stext),和uboot一样,都是从汇编阶段开始的,因为对于kernel而言,还没进行栈的维护,所以无法使用c语言。_HEAD定义了后面代码属于段名为.head .text的段。         内核起始部分代码被解压代码调用,前面关于uboot的文章中有提到过(eg:zImage)。uboot启动是无条件的,只要代码的位置对,上电就工作,kern

CentOS下mysql数据库data目录迁移

https://my.oschina.net/u/873762/blog/180388        公司新上线一个资讯网站,独立主机,raid5,lamp架构。由于资讯网是面向小行业,初步估计一两年内访问量压力不大,故,在做服务器系统搭建的时候,只是简单分出一个独立的data区作为数据库和网站程序的专区,其他按照linux的默认分区。apache,mysql,php均使用yum安装(也尝试