有些人安装的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 #设置防火墙开机启动

Centos 7 关于防火墙的命令的更多相关文章

  1. CentOS 7 开放防火墙端口命令

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  2. CentOS 7 开放防火墙端口 命令(转载)

    CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现以前CentOS 6 系列中的 iptables 相关命令不能用了,查了下,发现Centos 7使用fire ...

  3. linux 安装禅道 和 CentOS 7 开放防火墙端口 命令

    linux 安装禅道链接:  https://www.cnblogs.com/maohuidong/p/9750202.html CentOS 7 开放防火墙端口 命令 链接:https://www. ...

  4. CentOS 7中防火墙 firewall-cmd命令

    在 CentOS 7 iptable 防火墙已经被 firewall替代 1.暂时开放FTP服务 firewall-cmd --add-service=ftp 2.永久开放FTP服务 firewall ...

  5. CentOS 7 开放防火墙端口 命令

    iptables防火墙 1.基本操作 # 查看防火墙状态 service iptables status   # 停止防火墙 service iptables stop   # 启动防火墙 servi ...

  6. CentOS 7 开放防火墙端口

    我:最近在使 CentOS 7时发现在本地不能访问linux上8080端口,以上是我的操作,修改后访问成功 CentOS 7 开放防火墙端口 命令 最近公司新的server要求用CentOS7, 发现 ...

  7. CentOS 7.0关闭服务器的防火墙服务命令

    1.直接关闭防火墙systemctl stop firewalld.service #停止firewallsystemctl disable firewalld.service #禁止firewall ...

  8. centos 防火墙相关命令

    防火墙关闭: systemctl stop firewalld systemctl disable firewalld 重启防火墙: systemctl enable firewalld system ...

  9. linux(centos) 项目部署阶段相关命令汇总

    1.ssh免密码登陆主要命令cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys-->添加公钥service sshd restart -- ...

  10. 161118、linux(centos) 项目部署阶段相关命令汇总

    1.ssh免密码登陆 主要命令 cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys-->添加公钥 service sshd restart ...

随机推荐

  1. SMMS图床Java接口上传

    前言 个人项目开发中,网站建设中需要用到大量的图片以及用户上传的图片,如果服务器带宽小,磁盘容量小将所有的图片信息全部存储在服务器上不太现实,这里建议将图片数据存储在对象存OSS上或者将图片保存在图床 ...

  2. 2025AI应用元年,DeepSeek让领域小模型训练成本急剧下降!

    关注公众号回复1 获取一线.总监.高管<管理秘籍> 模型训练俗称炼丹,而炼丹是修士特权,这就显得模型训练离普通人很远了. 虽然是笑谈,但如果对其中情况不太了解确实也会因为其背后深厚.复杂的 ...

  3. js提示Cannot read property ‘replace‘ of undefined

    JS提示Cannot read property 'replace' of undefined 出现这个错误的原因一般是传的参数为null 在传参之前加个是否为null的判断可以解决异常.

  4. Shell - [01] 概述

    一.shell是什么 Shell 是一个命令解释器,接收应用程序/用户命令去调用操作系统内核. Shell 是一个功能强大的编程语言,易编写.易调试.灵活性强. 二.shell的解析器有哪些 [roo ...

  5. 启动Eclipse时报错如何解决?

    启动Eclipse出现弹框,弹框报错内容如下: A Java Runtime Enviroment(JRE)or Java Development Kit(JDK) must be available ...

  6. 探秘Transformer系列之(12)--- 多头自注意力

    探秘Transformer系列之(12)--- 多头自注意力 目录 探秘Transformer系列之(12)--- 多头自注意力 0x00 概述 0x01 研究背景 1.1 问题 1.2 根源 1.3 ...

  7. Linux重启php-fpm

    前言 PHP-FPM 是一款简单好用的 PHP FastCGI 进程管理工具. 它可以和 Apache.Nginx 或其他服务器一起构建完整的 PHP 环境. 接下来我们看看在更改了 php.ini ...

  8. Chrome设置header请求响应头 Chrome ModHeader插件,添加/修改/删除HTTP请求标头和响应标头

    ModHeader,是一款可以添加/修改/删除请求标头和响应标头的浏览器插件. ModHeader插件功能 首先,ModHeader插件支持添加/修改/删除请求标头和响应标头,并可以启用基于URL / ...

  9. 认识webRTC

    什么是 WebRTC 2010 年 5 月,谷歌收购了 Global IP Solutions(简称 GIPS),这是一家专注于 VoIP 和视频会议软件的公司,已开发出 RTC 所需的多项关键组件, ...

  10. 动态规划--最长公共子序列( LCS 问题)

    博客地址:https://www.cnblogs.com/zylyehuo/ # -*- coding: utf-8 -*- # 最长公共子序列的长度 def lcs_length(x, y): m ...