linux系统中防火墙管理有2种方式,分别是iptables和firewalld(centos7.x),下面介绍centos7的配置方法

一、firewalld:

因为cenos7默认使用firewalld作为防火墙管理,这里先介绍firewalld方式:

教程只说明特殊情况(卸载Firewall并安装iptables后重新安装回Firewall),其他情况比如默认的,没有装过iptables(从步骤4或7开始)都包含其中:

1. 首先停止和禁用iptables: 

  systemctl stop iptables && systemctl disable iptables

2. 

  systemctl unmask firewalld.service

3. 

  yum install firewalld

4.

  systemctl start firewalld.service

5.

  systemctl enable firewalld.service

6. 在不改变状态的条件下重新加载防火墙

  firewall-cmd --reload

7. 开启某个端口(可以范围开启如:xxxadd-port=8080-8088/tcp

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

8. 修改配置后需要重启服务使其生效

  systemctl restart firewalld.service

9. 如果不生效可重启系统生效

  reboot

注: 

查看开启的端口和服务

  firewall-cmd --permanent --zone=public --list-services    //服务空格隔开  例如 dhcpv6-client https ss  

  firewall-cmd --permanent --zone=public --list-ports    //端口空格隔开  例如  8080-8081/tcp 8388/tcp 80/tcp

查看某个端口是否生效

  firewall-cmd --zone=public --query-port=8080/tcp      //查看服务是否生效(例:添加的端口为8080)

参考:https://blog.csdn.net/Joe68227597/article/details/75207859

二、itables:

--关闭firewall:

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

--安装安装iptables防火墙

 yum install iptables-services            #安装

--清空已有的规则

iptables -F
iptables -X
iptables -Z

--开放特定的端口,以80为例

iptables -A INPUT -p tcp --dport 80 -j ACCEPT

 --保存配置

service iptables save

--重启

systemctl restart iptables.service

--设置开机自启动

systemctl enable iptables.service 

--重启系统使其生效

												

linux(centos7)防火墙配置firewalld和iptables的更多相关文章

  1. [转帖]Centos7防火墙配置rich-rule实现IP端口限制访问

    Centos7防火墙配置rich-rule实现IP端口限制访问 2019-02-18 18:05:35 sunny05296 阅读数 2143  收藏 更多 分类专栏: Linux   版权声明:本文 ...

  2. Linux(CentOS7)下配置多个tomcat

    记录 Linux(CentOS7) 下配置多个 tomcat 的操作过程. 一.下载tomcat 前提:安装配置好jdk环境,未配置可参考Linux(CentOS7)下安装jdk1.8. 从 tomc ...

  3. Linux CentOS7 安装配置 IPtables

    2021-08-11 1. 前言 防火墙其实就是实现 Linux 下访问控制功能的,分为硬件和软件的防火墙两种类型.无论在何网络中,防火墙工作的地方一定是网络的边缘.防火墙的策略.规则就是去定义防火墙 ...

  4. CentOS7 防火墙配置firewall-cmd

    firewalld(Dynamic Firewall Manager of Linux systems,Linux系统的动态防火墙管理器)服务是默认的防火墙配置管理工具. firewall-cmd 是 ...

  5. CentOS7防火墙管理firewalld

    学习apache安装的时候需要打开80端口,由于centos 7版本以后默认使用firewalld后,网上关于iptables的设置方法已经不管用了,想着反正iptable也不太熟悉,索性直接搬官方文 ...

  6. CentOS7 防火墙配置(关闭)

    CentOS7 的防火墙配置跟曾经版本号有非常大差别,经过大量尝试,最终找到解决这个问题的关键 CentOS7这个版本号的防火墙默认使用的是firewall.与之前的版本号使用iptables不一样. ...

  7. Centos7 防火墙关闭和启用iptables防火墙

    操作系统环境:CentOS Linux release 7.0.1406(Core) 64位CentOS 7.0默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤. 1.关闭f ...

  8. CentOS7 防火墙配置-详解

    CentOS 7 防火墙配置 1.防火墙的简述 防火墙对服务器起到一定的保护作用,所以了解一些相关的操作是很有必要的. 在CentOS 7.x中,有了一种新的防火墙策略叫FireWall , 在6.x ...

  9. Centos7防火墙关闭和启用iptables操作

    https://yq.aliyun.com/ziliao/33590前序 还是docker惹得最近做的系统都是上的centos7的系统带来的一系列的新环境的适应 补记下:在使用oracle vmbox ...

随机推荐

  1. Android 开发自己的网络收音机4——读取XML文件的电台数据

    国内外的电台数据很多,起码有好几百,所以把这些数据都写到代码里面是不实际的.只能写成一个数据文件,程序启动的时候再去加载.保存这些简单数据,我们肯定会优先使用XML文件,今天讲讲如何读取XML里面的数 ...

  2. Linux nginx目录设置

    上一节记录了nginx的安装,这里来试着修改下配置文件. #user nobody; worker_processes 1; #error_log logs/error.log; #error_log ...

  3. 【转】jsp+servlet和SSM分别是如何实现文件上传(示例)

    原文地址:https://blog.csdn.net/niceliusir/article/details/78453560 以下是jsp+servlet和SSM分别是如何实现文件上传的方法示例 两种 ...

  4. git pull出现There is no tracking information for the current branch

    使用git pull 或者 git push 的时候报错 gitThere is no tracking information for the current branch. Please spec ...

  5. MEMCACHE分布式算法(PHP)

    //测试分布式算法 $ports = array('端口1', '端口2', '端口3', '端口4', '端口5'); //Memcache端口 $users = array('1000', '10 ...

  6. Winform鼠标滑轮控制自定义滚动条

    场景:类似QQ聊天的窗体中,需要添加自定义滚动条vScroll.主窗体中panel存放空间,右边有垂直的滚动条vScroll. 问题:已经实现vScroll和Panel.VerticalScroll滚 ...

  7. <【彼得林奇 投资选股智慧全集】>读书笔记

    书在这里 投资公司而不是投资股市 好公司的股票迟早会有良好的表现 构建投资组合,降低投资风险 股票只是表象,上市公司才是实质,你要做的,就是搞清楚企业状况 要投资与企业,而不是投机于股市 评价股票的价 ...

  8. CubieTruck入手第一天

    基本的參考资料整理例如以下: mod=viewthread&tid=160" id="thread_subject" style="word-wrap: ...

  9. VS2013安装MVC5

    打开VS 选择  .net 4.5 创建项目 右击项目 选择管理NuGet 输入Microsoft.AspNet.Mvc -Version 5.0.0 安装最新版本的MVC5

  10. iOS应用跳转到App Store评分

    iOS应用跳转到App Store评分 1.跳转到应用评价页 NSString *urlStr = [NSString stringWithFormat:@"itms-apps://itun ...