一、CentOS 7 以下版本防火墙的配置:

1.开放80,22,8080 端口
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 22 -j ACCEPT
/sbin/iptables -I INPUT -p tcp --dport 8080 -j ACCEPT
2.保存
/etc/rc.d/init.d/iptables save
3.查看打开的端口
/etc/init.d/iptables status
4.关闭防火墙
1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop

二、CentOS 7 不再使用原来的iptables,启用firewall

1、firewalld的基本使用

启动: systemctl start firewalld
关闭: systemctl stop firewalld
查看状态: systemctl status firewalld 
开机禁用  : systemctl disable firewalld
开机启用  : systemctl enable firewalld
 
 
2、systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

启动一个服务:systemctl start firewalld.service
关闭一个服务:systemctl stop firewalld.service
重启一个服务:systemctl restart firewalld.service
显示一个服务的状态:systemctl status firewalld.service
在开机时启用一个服务:systemctl enable firewalld.service
在开机时禁用一个服务:systemctl disable firewalld.service
查看服务是否开机启动:systemctl is-enabled firewalld.service
查看已启动的服务列表:systemctl list-unit-files|grep enabled
查看启动失败的服务列表:systemctl --failed

3、配置firewalld-cmd

查看版本: firewall-cmd --version
查看帮助: firewall-cmd --help
显示状态: firewall-cmd --state
查看所有打开的端口: firewall-cmd --zone=public --list-ports
更新防火墙规则: firewall-cmd --reload
查看区域信息:  firewall-cmd --get-active-zones
查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:firewall-cmd --panic-on
取消拒绝状态: firewall-cmd --panic-off
查看是否拒绝: firewall-cmd --query-panic
 
4、配置一个端口,如80
查看已开放的端口(默认不开放任何端口)
firewall-cmd --list-ports
添加
firewall-cmd --zone=public(作用域) --add-port=80/tcp(端口和访问类型) --permanent(--permanent永久生效,没有此参数重启后失效)
重新载入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
删除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
 
原文参考:
https://blog.csdn.net/u013410747/article/details/61696178
https://www.cnblogs.com/moxiaoan/p/5683743.html

CentOS 7 与老版本CentOS防火墙配置的区别的更多相关文章

  1. Centos安装Python各版本解释器并配置pip

    Centos7.3安装Python3.7 Python3.7貌似又多了新的依赖,所以按照安装之前的套路安装在配置pip阶段就会出问题,比如: ModuleNotFoundError: No modul ...

  2. H3C TE老版本OSPF正确配置

    R1配置: ---------------------------------------------------- # sysname RT1# super password level 3 cip ...

  3. Spring boot2.0 与 2.0以前版本 跨域配置的区别

    一·简介 spring boot升级到2.0后发现继承WebMvcConfigurerAdapter实现跨域过时了,那我们就紧随潮流. 二·全局配置 2.0以前 支持跨域请求代码: import or ...

  4. Ubuntu离线安装Sogou拼音(附老版本安装&输入法自启动)

    跨平台系列汇总:http://www.cnblogs.com/dunitian/p/4822808.html#linux 离线安装的基础可以看看这篇文章的 前期准备工作 http://www.cnbl ...

  5. 【转】SpringBoot 2.0.0新版和SpringBoot1.5.2版本中Tomcat配置的差别

    https://blog.csdn.net/wd2014610/article/details/79587161 2018年春SpringBoot 2.0.0 新版本有了很多新的改变,其中Tomcat ...

  6. Centos 6.5 SNMP客户端安装及配置版本net-snmp-5.7.3

    Centos 6.5 SNMP客户端安装及配置SNMP版本:net-snmp-5.7.3.tar.gz1.下载软件cd /usr/local/srcyum -y install gccwget htt ...

  7. CentOS 7.x下升级Python版本到3.x系列(新老版本共存)

    由于python官方已宣布2.x系列即将停止支持,为了向前看,我们升级系统的python版本为3.x系列服务器系统为当前最新的CentOS 7.4 1.安装前查看当前系统下的python版本号 # p ...

  8. CentOS 8及以上版本配置IP的方法,你 get 了吗

    接上篇文章讲了 Ubuntu 18及以上版本的配置方法,本文再来讲讲 CentOS 8 及以上版本配置 IP 的方法. Centos/Redhat(8.x) 配置 IP 方法 说明:CentOS 8 ...

  9. centOs下的php+mysql+apache+ftp配置

    在安装服务器时做了相应的笔记,这个方法是亲身经验成功的,随着版本的不断更新,也许会有一些地方不同,但是基本原理都是一样的. 1.安装CentOS 6 ,可以选择最小安装,也可以安装桌面 2.升级系统 ...

随机推荐

  1. log4j与commons-logging slf4j的关系

    1. slf4j     他只提供一个核心slf4j api(就是slf4j-api.jar包),这个包只有日志的接口并没有实现     所以如果要使用就得再给它提供一个实现了些接口的日志包,     ...

  2. github后端开发面试题大集合(一)

    作者:小海胆链接:https://www.nowcoder.com/discuss/3614?type=0&order=0&pos=5&page=0?from=wb来源:牛客网 ...

  3. CVE-2010-2883Adobe Reader和Acrobat CoolType.dll栈缓冲区溢出漏洞分析

       Adobe Acrobat和Reader都是美国Adobe公司开发的非常流行的PDF文件阅读器. 基于Window和Mac OS X的Adobe Reader和Acrobat 9.4之前的9.x ...

  4. js中的Object.seal()与Object.freeze()

    关键字:seal, freeze, property descriptor. 1.Object.seal() 参考文档(2)中这样描述: The Object.seal() method seals ...

  5. jboss各种测试方式归类

      不跨工程访问(如:HBase) 跨工程访问(如:Business) 不部署到服务器上 部署到服务器上 不部署到服务器上 部署到服务器上 Junit测试 实例化直接调用 true true Fals ...

  6. Decorator 装饰

    意图 动态地给一个对象添加一些额外的职责.就增加功能来说,Decorator模式相比生成子类更为灵活. 结构 Component:定义一个对象接口,可以给这些对象动态地添加职责:(纯虚函数) Conc ...

  7. C语言:打印A-Z字母组合的菱形图案

    题目: +++++++++A+++++++++++++++++BCD+++++++++++++++EFGHI+++++++++++++JKLMNOP+++++++++++QRSTUVWXY++++++ ...

  8. python开发之路Day17-算法设计(冒泡排序、选择排序、插入排序、二叉树)

    s12-20160514-day17 *:first-child { margin-top: 0 !important; } body>*:last-child { margin-bottom: ...

  9. Sample ASP.NET IHttpHandler

    LoggerHandler.cs using System; using System.Collections.Generic; using System.Diagnostics; using Sys ...

  10. spring boot之使用通用Mapper批量添加数据

    通用Mapper是一款针对mybatis进行扩展的轻量级组件,使用起来非常方便.当调用其针对mysql进行批量添加数据的方法时,发现报错,仔细研究了一番,发现是在使用通用Mapper上出现了问题.下面 ...