有些人安装的linux的系统默认防火墙不是iptables,而是firewall,那就得使用以下方式关闭防火墙了。

>>>关闭防火墙

systemctl stop firewalld.service            #停止firewall
systemctl disable firewalld.service        #禁止firewall开机启动

>>>开启端口

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

命令含义

--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效

>>>重启防火墙

firewall-cmd --reload

其他常用命令:

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                              ##查看帮助

更多命令,使用 firewall-cmd --help 查看帮助文件

>>> CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下

1、直接关闭防火墙

systemctl stop firewalld.service          #停止firewall
systemctl disable firewalld.service    #禁止firewall开机启动

2、设置 iptables service

yum -y install iptables-services
如果要修改防火墙配置,如增加防火墙端口3306
vi /etc/sysconfig/iptables
增加规则
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT

保存退出后
systemctl restart iptables.service #重启防火墙使配置生效
systemctl enable iptables.service #设置防火墙开机启动

Centos7防火墙常用命令的更多相关文章

  1. Centos7防火墙常用命令及mask锁定不能添加端口问题

    一.开放端口 sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent sudo firewall-cmd --reload 二. ...

  2. Centos7 防火墙常用命令 开启 关闭防火墙

    如果你的系统上没有安装使用命令安装 #yum install firewalld  //安装firewalld 防火墙 开启服务 # systemctl start firewalld.service ...

  3. linux下防火墙开启某个端口号及防火墙常用命令使用

    linux防火墙常用命令 1.永久性生效,重启后不会复原 开启:chkconfigiptables on 关闭:chkconfigiptables off 2.即时生效,重启后复原 重启防火墙 方式一 ...

  4. 【CentOS7】常用命令

    [CentOS7]常用命令 转载:https://www.cnblogs.com/yangchongxing/p/10646640.html 目录 ========================== ...

  5. Centos7 防火墙常用配置及说明

    一. Centos7和Centos6 防火墙的区别: 使用的工具不一样了.Centos6 使用的是iptables ,Centos7 使用的是filewall iptables 用于过滤数据包,属于网 ...

  6. iptables防火墙常用命令

    iptables防火墙启动停止和基本操作 iptables是centos7之前常用的防火墙,在centos7上使用了firewall 防火墙基本操作: # 查询防火墙状态 service iptabl ...

  7. Fortigate防火墙常用命令

    命令结构 #config 对策略,对象等进行配置 #get  查看相关对象的参数 #show 查看配置文件 #diagnose 诊断命令 #execute  常用的工具命令,如ping treacer ...

  8. centos6和centos7中常用命令区别

    以前一直接触的是centos6,最近因为新项目接触到centos7,发现有些命令还是有差异的(从centos7开始使用systemctl来管理服务和程序,包括了service和chkconfig),现 ...

  9. CentOS7.5常用命令

    常用命令: 关机shutdown -h now 参数:重启-r定时-r 23:59 分-r 10 查源软件yum list |grep telnet参数:安装install 服务启动systemctl ...

随机推荐

  1. 初学Java 二维数组找出最近的两个点

    import java.util.Scanner; public class FindNearestPoints { public static void main(String[] args) { ...

  2. .OnCommand mfc

    .OnCommand是响应WM_COMMAND消息的,一般是响应控件和菜单的命令消息时使用. 如果 WM_COMMAND 来自控件的话 lParam 就是发送这个 WM_COMMAND 消息的控件的句 ...

  3. 文本框的SelectionDirection属性

    代码实例: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF ...

  4. centos 6.5 安装 nginx

    从nginx官网下载安装包:nginx-1.8.1.tar.gz,解压 tar xvf nginx-1.8.1.tar.gz -C /usr/local 安装依赖 yum install gcc yu ...

  5. Task10.Bert

    Transformer原理 论文地址:Attention Is All You Need:https://arxiv.org/abs/1706.03762 Transformer是一种完全基于Atte ...

  6. BZOJ 1096: [ZJOI2007]仓库建设 动态规划 + 斜率优化

      #include<bits/stdc++.h> #define setIO(s) freopen(s".in","r",stdin) #defi ...

  7. IntelliJ IDEA 装配FindBugs以及应用

    IntelliJ IDEA 安装FindBugs以及应用 众所周知,项目越来越大,开发人员越来越多,我们的代码审查工作会变得越来越复杂,对代码质量控制难度也与日俱增,尽管经验丰富的程序员能审查能检查出 ...

  8. python中私有属性的访问

    class MyClass(): def __init__(self): self.__superprivate = "Hello" self.__semiprivate = &q ...

  9. Charles抓取https

    步骤一:将Charles的根证书(Charles Root Certificates)安装到Mac上. Help -> SSL Proxying -> Install Charles Ro ...

  10. I/O等待事件-db file scattered read

    摘自:http://blog.csdn.net/zq9017197/article/details/7925338