之前用的iptables来管理的防火墙,后来发现centOS7.0中已经用firewalld取代iptables了,于是与时俱进,停用了iptables。

systemctl stop iptables.service

然后来启动firewalld吧

systemctl start firewalld.service

给我报了这个错

Failed to start firewalld.service: Unit firewalld.service is masked.

查了很久没找到解决办法,于是试着输入了下面这行命令,解决了。

systemctl unmask firewalld.service

启动firewalld.service

systemctl start firewalld.service

把80端口添加到防火墙开放端口中

firewall-cmd --permanent --zone=public --add-port=80/tcp

重启一遍firewalld服务使其生效

systemctl restart firewalld.service

检查更改是否生效

firewall-cmd --zone=public --query-port=80/tcp
发现在CentOS 7上开放端口用iptables没效果(或者是sodino没找到正确的命令,传说Centos7 下默认的防火墙是 Firewall,替代了之前的 iptables)…

使用firewall-cmd开放端口则立即就生效了。
见下操作:

1
2
3
4
5
6
7
firewall-cmd --state //查看运行状态
 
// 开放1024的端口
firewall-cmd --add-port=1024/tcp permanent
 
// 重载生效刚才的端口设置
firewall-cmd --reload

效果见下图:

firewall常用命令如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
常用命令介绍
 
firewall-cmd --state ##查看防火墙状态,是否是running
firewall-cmd --reload ##重新载入配置,比如添加规则之后,需要执行此命令
firewall-cmd --get-zones ##列出支持的zone
firewall-cmd --get-services ##列出支持的服务,在列表中的服务是放行的
firewall-cmd --query-service ftp ##查看ftp服务是否支持,返回yes或者no
firewall-cmd --add-service=ftp ##临时开放ftp服务
firewall-cmd --add-service=ftp --permanent ##永久开放ftp服务
firewall-cmd --remove-service=ftp --permanent ##永久移除ftp服务
firewall-cmd --add-port=80/tcp --permanent ##永久添加80端口
iptables -L -n ##查看规则,这个命令是和iptables的相同的
man firewall-cmd ##查看帮助

centOS7.0配置防火墙的更多相关文章

  1. Linux centos7.0 配置防火墙及开放端口

    现在防火墙有两种服务1.service firewalld 2.service iptables 一.就firewalld来说查看开放的端口  netstat  -anp 查询防火墙状态  servi ...

  2. CentOS7下配置防火墙放过Keepalived

    Keepalived是一个轻量级的HA集群解决方案,但开启防火墙后各节点无法感知其它节点的状态,各自都绑定了虚拟IP.网上很多文章讲要配置防火墙放过tcp/112,在CentOS7下是无效的,正确的做 ...

  3. Centos7.0关闭防火墙

    CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下 1.直接关闭防火墙 systemctl stop firewalld.service #关闭firew ...

  4. centos7.0 关闭防火墙

    1.关闭firewall:systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止fire ...

  5. Centos7.0配置Hadoop2.7.0伪分布式

    一.ssh免密登录 1.命令ssh-keygen. overwrite输入y一路回车 2.将生成的密钥发送到本机 ssh-copy-id localhost中间会询问是否继续输入“yes” 3.测试免 ...

  6. 新装Centos7.2 配置防火墙

    1.安装 yum -y install firewalld2.开机启动 systemctl enable firewalld3.设置防火墙规则 systemctl restart firewalld ...

  7. Centos7.0 配置docker 镜像加速

    在Docker Hub官网上注册帐号,即可下载使用仓库里的全部的docker镜像.而因为网络原因,国内的开发者没办法流畅的下载镜像,经常会出现下载中断的错误.解决方法就是使用国内的容器Hub加速服务, ...

  8. Centos7.0配置MySQL主从服务器

    主服务器:192.168.186.131 从服务器:192.168.186.133 主从服务器mysql版本尽量保持一致,安装步骤请阅mysql安装步骤 一.修改主服务器配置文件 #   vi /et ...

  9. CentOS 7.0 配置防火墙

    停用了 iptables. systemctl stop iptables.service 然后来启动 firewalld 吧 systemctl start firewalld.service 给我 ...

随机推荐

  1. select、poll和epoll多路I/O复用

    一.三者的区别 select  select最早于1983年出现在4.2BSD中,它通过一个select()系统调用来监视多个文件描述符的数组,当select()返回后,该数组中就绪的文件描述符便会被 ...

  2. leetcode 刷题日志 2018-03-26

    58. 最后一个单词的长度 分析:找最后一个非空格,向前找 int lengthOfLastWord(string s) { int i = s.find_last_not_of(' '); int ...

  3. LightOJ1214 Large Division 基础数论+同余定理

    Given two integers, a and b, you should check whether a is divisible by b or not. We know that an in ...

  4. Log-structured File Systems

    换到博客园排版有问题,原版在这里:http://xubenbenhit.github.io/LogStructureFileSystem.html Log-structured File System ...

  5. (4.2)基于LingPipe的文本基本极性分析【demo】

    酒店评论情感分析系统(四)—— 基于LingPipe的文本基本极性分析[demo] (Positive (favorable) vs. Negative (unfavorable)) 这篇文章为Lin ...

  6. Elasticsearch技术解析与实战(七)Elasticsearch批量操作

    批量查询 1.如果查询的document是不同index下的不同type种的话 GET /_mget { "docs" : [ { "_index" : &qu ...

  7. 如何发布一个自定义Node.js模块到NPM(详细步骤,附Git使用方法)

    咱们闲话不多说,直接开始! 由于我从没有使用过MAC,所以我不保证本文中介绍的操作与MAC一致. 文章开始我先假定各位已经在window全局安装了Node.js,下面开始进行详细步骤介绍: 本文本着, ...

  8. 新手应知道的ASP.NET代码编写规范

    1.局部变量的名称要有意义,尽量用对应的英文命名,比如“用户姓名”变量,不要用aa bb cc等来命名,而要使用userName. 2.不要使用单个字母的变量,如i.n.x等.而要使用index.te ...

  9. 强大的jQuery网格插件 ParamQuery

    ParamQuery是一种轻量级的jQuery网格插件,基于用于用户界面控制.具有一致API的优秀设计模式jQueryUI Widget factory创建,能够在网页上展示各种类似于Excel和Go ...

  10. [POJ3370]&[HDU1808]Halloween treats 题解(鸽巢原理)

    [POJ3370]&[HDU1808]Halloween treats Description -Every year there is the same problem at Hallowe ...