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

于是就往这方面查问题,发现没有iptables文件,然后我启动iptables服务,报错。

Centos 7在启动iptables(防火墙)时报错:
Failed to start IPv4 firewall with iptables.

原因:因为centos7.0默认不是使用iptables方式管理,而是firewalld方式。Centos6.0防火墙用iptables管理。(原来是这样,centos7默认防火墙时firewalld啊[笑哭]。:-D)

解决办法有两个:一是继续使用默认的firewalld方式。二是关闭firewalld,然后安装iptables。以前都是用iptables,所以想换回来,于是找到如下切换教程。

从firewalld切换到iptables:关闭firewalld安装iptables

1、首先执行如下命令

1#关闭
2systemctl stop firewalld
3systemctl mask firewalld

2、然后安装iptables-services

1#安装
2yum install iptables-services
3#设置开机启动
4systemctl enable iptables

3、开放443端口(HTTPS)

iptables -A INPUT -p tcp --dport 443 -j ACCEPT

4、保存防火墙配置

1service iptables save
2#或者
3/usr/libexec/iptables/iptables.init save

5、iptables的一些命令,停止/启动/重启 防火墙:

1systemctl [stop|start|restart] iptables
2#或者
3service iptables [stop|start|restart]

然后启动iptables服务,这样就搞定了。

但是,从firewalld切换到iptables后会有这样那样的问题,还不如用系统默认的。

从iptables切换回firewalld

1、先看firewalld的状态:inactive
systemctl status firewalld

2、安装firewalld
yum install firewalld

3、切换

1#关闭iptables
2systemctl mask iptables
3systemctl stop iptables
4#切换
5systemctl unmask friewalld
6systemctl start friewalld

总算恢复了。

饶了一大圈,最后找到这篇文章
windows本地连不上虚拟机redis服务完美解决,解决了这个问题。

附:firewalld相关命令

常用命令

 1#查看状态,是否已经安装firewalld
2systemctl status firewalld
3#开启防火墙
4systemctl startfirewalld.service
5#关闭防火墙
6systemctl stop firewalld.service
7#设置开机自动启动
8systemctl enable firewalld.servic
9#设置关闭开机制动启动
10systemctl disable firewalld.service
11#在不改变状态的条件下重新加载防火墙
12firewall-cmd --reload

启用某个服务

1#临时
2firewall-cmd --zone=public --add-service=https
3#永久
4firewall-cmd --permanent --zone=public --add-service=https

开启某个端口

1#永久
2firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp
3#临时
4firewall-cmd  --zone=public --add-port=8080-8081/tcp

查看开启的端口和服务

1#查看开启的服务 空格隔开
2firewall-cmd --permanent --zone=public --list-services
3#查看开启的端口 空格隔开
4firewall-cmd --permanent --zone=public --list-ports
5#修改配置后需要重启服务使其生效
6systemctl restartfirewalld.service
7#查看服务是否生效 (例:添加的端口为8080)
8firewall-cmd --zone=public --query-port=8080/tcp 

如下,查看开启的服务、端口

Centos7启动防火墙时报错Failed to start IPv4 firewall with iptables的更多相关文章

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

    用iptables开启防火墙报错: Failed to start  IPv4 firewall with iptables. 转载于:https://blog.csdn.net/ls1645/art ...

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

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

  3. 启动Genymotion时报错Failed to initialize backend EGL display

    在启动Genymotion的时候报错: video card说的是显卡,你的显卡可能不支持  OpenGL2.0,或者你装的驱动有问题. 解决办法:将驱动重新安装一下. 可直接下载一个如“驱动人生“一 ...

  4. centos7启动网卡报错(Failed to start LSB: Bring up/down networking )

    systemctl status network.service systemctl stop NetworkManager systemctl disable NetworkManager syst ...

  5. 用Eclipse的tomcat插件启动tomcat时报错:

    用Eclipse的tomcat插件启动tomcat时报错: FATAL ERROR in native method: JDWP No transports initialized, jvmtiErr ...

  6. MyEclipse 启动tomcat时报错:Cannot change deployment state from ERROR to REDEPLOYING.ds

    myeclipse 启动tomcat时报错:Cannot change deployment state from ERROR to REDEPLOYING.ds - 刘琦的专栏 - 博客频道 - C ...

  7. 【原创】大叔经验分享(57)hue启动coordinator时报错

    hue启动coordinator时报错,页面返回undefinied错误框: 后台日志报错: runcpserver.log [13/May/2019 04:34:55 -0700] middlewa ...

  8. 启动outlook时报错:mapi无法加载信息服务msncon.dll

    今天这个Office2010 outlook搞的让人蛋疼,老是说启动outlook时报错:mapi无法加载信息服务msncon.dll. 百度了一下,如下解决方案: 安装路径为D:\NEW Windo ...

  9. vmware启动winodws时报错弹出【无法连接MKS:套接字连接尝试次数太多;正在放弃;】

    启动虚拟机时报错 解决办法:(其实就是有关于虚拟机的服务没有起) win+R输入services.msc,将所有有关vmware的服务都起起来即可

随机推荐

  1. Chapter 07-Basic statistics(Part1 描述统计数据)

    在这一部分中,仍然使用mtcars(Motor Trend Car Road Tests)这一数据集,以及mpg(one mile per gallon), hp(horsepower), wt(we ...

  2. tcp协议传输方法&粘包问题

    socket实现客户端和服务端 tcp协议可以用socket模块实现服务端可客户端的交互 # 服务端 import socket #生成一个socket对象 soc = socket.socket(s ...

  3. Mac系统安装文件提示文件已损坏,打不开解决办法

    Mac系统安装文件提示文件已损坏,打不开解决办法: 修改系统配置:系统偏好设置 - 安全性与隐私 - 任何来源”.如果没有“任何来源”这个选项,是因为你的系统是macOS Sierra 10.12,苹 ...

  4. 如何对IP地址进行子网划分?

    在网络行业,子网划分是必须掌握的的基础知识点,下图是IP地址分类: 子网划分主要掌握的是划分思路,接下来我以192.168.1.72/27的IP划分做为例子: CIDR:无类域间路由. 可以看出192 ...

  5. NetCore 3.0 中使用Swagger生成Api说明文档及升级报错原因

    认识Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.总体目标是使客户端和文件系统作为服务器以同样的速度来更新.文件的方法,参 ...

  6. k8s 开船记-首航:博客站点从 docker swarm 切换到 k8s

    昨天晚上,我们将博客站点的生产环境从 docker swarm 集群切换到了 k8s 集群,开船到目前,航行非常平稳,可以说首航成功! k8s 集群是我们用10台阿里云服务器自己搭建的,1台 mast ...

  7. 主题: 002.04 Tkinter 星空大战

    为了更加熟练 Tkinter 的应用,决定只用 Tkinter 来写一个游戏,而不是用 Pygame, 在过程中,出了很多很大的问题,最后留了一点已知的问题,不想在花时间去找出来,不过整个程序算跑的没 ...

  8. AddTransient、AddSingleton、AddScoped的区别

    权重: AddSingleton→AddTransient→AddScoped AddSingleton的生命周期: 项目启动-项目关闭   相当于静态类  只会有一个 AddScoped的生命周期: ...

  9. 笔记||Python3之模块与包

    模块的概念:一个.py文件就称之为一个模块. 包的概念:把许多个模块按照功能放到不同的目录中来组织模块,这些组织存放模块文件的目录,我们称之为包. 模块与包的优势:1- 方便别人调用 2 - 避免同名 ...

  10. 【前端知乎系列】ArrayBuffer 和 Blob 对象

    本文首发在 个人博客 更多丰富的前端学习资料,可以查看我的 Github: <Leo-JavaScript>,内容涵盖数据结构与算法.HTTP.Hybrid.面试题.React.Angul ...