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. LeetCode: Palindrome 回文相关题目

    LeetCode: Palindrome 回文相关题目汇总 LeetCode: Palindrome Partitioning 解题报告 LeetCode: Palindrome Partitioni ...

  2. LeetCode: Balanced Binary Tree 解题报告

    Balanced Binary Tree Given a binary tree, determine if it is height-balanced. For this problem, a he ...

  3. Android开发(八)——Android组件

    参考: [1] Android开发教程:理解Intent和Intent Filter.http://liuzhichao.com/p/506.html

  4. plot sin 动态配置rc settings

    plot sin 动态配置rc settings 坐标轴颜色 线的颜色 绘图前景色 Code #!/usr/bin/env python # -*- coding: utf-8 -*- import ...

  5. 【Unity笔记】根骨骼动画/运动(Root Motion)

    根骨骼动画:当动画中角色发生位移后,动作坐标原点跟随角色移动.例如一个向前跳跃的动画,如果在场景中重复该动画,能够看到角色一路往前跳跃,位置一直在前进.适用于有位移的放技能动作等. 非根骨骼动画:当动 ...

  6. C语言 · 计算时间

    算法提高 计算时间   时间限制:1.0s   内存限制:512.0MB      问题描述 给定一个t,将t秒转化为HH:MM:SS的形式,表示HH小时MM分钟SS秒.HH,MM,SS均是两位数,如 ...

  7. Docker常用命令<转>

    创建redis服务端docker run -p 6379:6379 -d --name redis-server docker.io/redis:3.0.7 redis-server -- port ...

  8. SpringBoot2 JPA No Identifier specified for entity的解决办法

    No Identifier specified for entity的错误 此类注解都在 import javax.persistence.*;包下     @Id     @GeneratedVal ...

  9. 修改ie11的默认搜索引擎和主页

    虚机自动升级到了ie11,但发现默认的主页.搜索引擎都无法修改,改完了重新打开ie又被重置成微软的东东.找了个帖子,发现只要修改c:\windows\system32\drivers\etc下的hos ...

  10. 快速排序算法(Quicksort)

    快速排序算法是对集合中元素进行排序最通用的算法,俗称快排,其算法的时间复杂度为O(nlgn),空间复杂度为O(1). 我们举例来对其算法思路进行理解,譬如数组 A = { 4, 8, 1, 2, 9, ...