之前用的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. grep index.php *

    zb@zb-computer:/usr/local/nginx/conf/vhost$ grep index.php * caomall17.conf: index index.html index. ...

  2. Splay 区间操作

    据大佬说,\(Splay\)是序列操作之王.\(Splay\)是一种平衡树,通过伸展(\(Splay\)),在不改变中序遍历的前提下变换根的位置,从而快速的进行序列操作 \(Splay\)最常见的序列 ...

  3. oracle导入提示IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件

    oracle导入提示:IMP-00013: 只有 DBA 才能导入由其他 DBA 导出的文件IMP-00000: 未成功终止导入 解决办法:用户缺少导入权限,授予用户导入权限grant imp_ful ...

  4. [DeeplearningAI笔记]序列模型2.3-2.5余弦相似度/嵌入矩阵/学习词嵌入

    5.2自然语言处理 觉得有用的话,欢迎一起讨论相互学习~Follow Me 2.3词嵌入的特性 properties of word embedding Mikolov T, Yih W T, Zwe ...

  5. /etc/rc.d/里文件的作用

    rc.sysinit指的是系统启动不管进哪个运行级别必须做的初始化工作, rcn.d目录指的是系统进对应n的运行级别时候系统必须做的工作,目录下S打头的服务指进此运行级别时候启动的服务,而K打头的指离 ...

  6. Python print "hello world" SyntaxError: invalid syntax

    刚安装Python,在IDLE中输入print “Hello World”,谁知却发生错误: >>> print "Hello World"SyntaxError ...

  7. 数据库-SQLite

    技术博客http://www.cnblogs.com/ChenYilong/ 新浪微博http://weibo.com/luohanchenyilong  数据库-SQLite 技术博客http:// ...

  8. HDU 1148 Rock-Paper-Scissors Tournament (模拟)

    题目链接 Problem Description Rock-Paper-Scissors is game for two players, A and B, who each choose, inde ...

  9. hdu 3729 I'm Telling the Truth(二分匹配_ 匈牙利算法)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=3729 I'm Telling the Truth Time Limit: 2000/1000 MS ( ...

  10. http状态码说明

    在学习网页设计的时候都应该知道状态码,但我们常见的状态码都是200,404,下面介绍其他的状态值 1开头的http状态码表示临时响应并需要请求者继续执行操作的状态代码. 100   (继续) 请求者应 ...