1. 程式人生 > >CentOS7--Firewalld防火牆

CentOS7--Firewalld防火牆

  Firewalld服務是紅帽RHEL7系統中預設的防火牆管理工具,特點是擁有執行時配置永久配置選項且能夠支援動態更新以及"zone"的區域功能概念,使用圖形化工具firewall-config或文字管理工具firewall-cmd

 配置檔案的位置:

  firewalld 的配置儲存在 /usr/lib/firewalld/ 和 /etc/firewalld/ 裡的各種 XML 檔案裡,firewalld 優先使用 /etc/firewalld/services/ 裡的檔案。

通過編輯 /etc/firewalld/services/ 中的 XML 檔案,服務可以被增加和刪除,/usr/lib/firewalld/services/

 檔案可以作為模板使用。

區域概念與作用:

  防火牆的網路區域定義了網路連線的可信等級,我們可以根據不同場景來呼叫不同的firewalld區域,區域規則有:

   特別需要注意的是firewalld服務有兩份規則策略配置記錄,必需要能夠區分:

    RunTime:當前正在生效的。

    Permanent:永久生效的。

當下面實驗修改的是永久生效的策略記錄時,必須執行"--reload"引數後才能立即生效,否則要重啟後再生效。

開啟firewalld

systemctl start firewalld
systemctl enable firewalld

檢視當前的區域:

[[email protected] ~]# firewall-cmd --get-default-zone
public

查詢網絡卡的區域:

[[email protected] ~]# firewall-cmd --get-zone-of-interface=eno16777736
public

在public中分別查詢ssh與http服務是否被允許:

[[email protected] ~]# firewall-cmd --zone=public --query-service=ssh
yes
[
[email protected]
~]# firewall-cmd --zone=public --query-service=http no

設定預設規則為dmz:

[[email protected] ~]# firewall-cmd --set-default-zone=dmz
success

讓“永久生效”的配置檔案立即生效:

[[email protected] ~]# firewall-cmd --reload
success

啟動/關閉應急狀況模式,阻斷所有網路連線:

應急狀況模式啟動後會禁止所有的網路連線,一切服務的請求也都會被拒絕,當心,請慎用。

[[email protected]Centos7 ~]# firewall-cmd --panic-on
success [[email protected]Centos7~]# firewall-cmd --panic-off
success

例項:

模擬訓練A:允許https服務流量通過public區域,要求立即生效且永久有效:

  方法一:分別設定當前生效與永久有效的規則記錄:

[[email protected] ~]#  firewall-cmd --zone=public --add-service=https
success
[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=https
success

  方法二:設定永久生效的規則記錄後讀取記錄:

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-service=https
success
[[email protected] ~]# firewall-cmd --reload
success

模擬訓練B:不再允許http服務流量通過public區域,要求立即生效且永久生效:

[[email protected] ~]# firewall-cmd --permanent --zone=public --remove-service=http
success

[[email protected] ~]# firewall-cmd --reload 
success

模擬訓練C:允許8080與8081埠流量通過public區域,立即生效且永久生效:

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp
success
[[email protected] ~]# firewall-cmd --reload 
success

模擬訓練D:檢視模擬實驗中的規則:

[[email protected] ~]# firewall-cmd --zone=public --list-services 
dhcpv6-client http https ssh
[[email protected] ~]# firewall-cmd --zone=public --list-ports 
8080-8081/tcp

模擬實驗F:設定富規則,拒絕192.168.10.0/24網段的使用者訪問ssh服務:

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.10.0/24" service name="ssh" reject"
success

 模擬實驗G:將訪問主機888埠的請求轉發至22埠:

[[email protected] ~]# firewall-cmd --permanent --zone=public --add-forward-port=port=888:proto=tcp:toport=22:toaddr=192.168.0.85
success
[[email protected] ~]# firewall-cmd --reload 
success

在別的機器訪問192.168.0.85(Centos7)

[[email protected] ~]$ ssh -p 888 192.168.0.85
[email protected]192.168.0.85's password: 
Last login: Mon Jan 16 17:22:42 2017 from 192.168.0.85
[[email protected] ~]# 
 圖形管理工具
執行firewall-config命令即可看到firewalld的防火牆圖形化管理工具,真的很強大,可以完成很多複雜的工作。

相關推薦

linux centos7 firewalld防火牆

防火牆的相關操作: 啟動:systemctl start firewalld 檢視狀態:systemctl status firewalld  停止: systemctl disable firewalld 禁用: systemctl stop firewalld

關於Centos7 firewalld防火牆開放埠後仍不能訪問ftp和nginx的問題解決

我在阿里輕量應用伺服器搭建ftp伺服器這篇部落格中把防火牆換為iptables,因為當時無論我怎麼設定firewalld,就是無法訪問ftp伺服器,今天在翻看其他部落格的時候,突然發現firewalld

CentOS7--Firewalld防火牆

  Firewalld服務是紅帽RHEL7系統中預設的防火牆管理工具,特點是擁有執行時配置與永久配置選項且能夠支援動態更新以及"zone"的區域功能概念,使用圖形化工具firewall-config或文字管理工具firewall-cmd  配置檔案的位置:   firewalld 的配置儲存在 /us

【linux】 --- centos7防火牆firewalld

一、firewalld介紹 CentOS 7中防火牆是一個非常的強大的功能,在CentOS 6.5中在iptables防火牆中進行了升級了。 二、firewalld配置 1、系統配置目錄 /usr/lib/firewalld/services 2.使用者配置目錄 /et

Centos7-----firewalld詳解

firewalld centos7 linux Centos7-----firewalld詳解 概述:Filewalld(動態防火墻)作為redhat7系統中變更對於netfilter內核模塊的管理工具;iptables service 管理防火墻規則的模式(靜態):用戶將新的防火墻規則添加進 /

centos7 firewalld基本配置方法

hit odi 規則 des all port add-port address https 說明:此規範分為兩部分:一是,常規配置方法;二是集合配置方法常規的配置方法是指對於端口,服務及源地址的限制方法集合配置方法是針對於源地址和端口組合限制,但源地址是一個IP地址集合,

Centos7.x防火牆配置

1、檢視firewall服務狀態 systemctl status firewalld 2、檢視firewall的狀態 firewall-cmd --state   3、開啟、重啟、關閉、firewalld.service服務 # 開啟 service fir

(轉)CentOS7防火牆的基本操作

目錄 1、firewalld簡介 2、安裝firewalld 3、執行、停止、禁用firewalld 4、配置firewalld 5 開啟埠 學習apache安裝的時候需要開啟80埠,由於centos 7版本以後預設使用firewalld後,網上關於ipt

CentOS 7上安裝配置FirewallD防火牆詳解

正確配置的防火牆是整個系統安全性中最重要的方面之一。 在本教程中,我們將向您展示如何在CentOS 7系統上使用FirewallD設定防火牆,並向您解釋基本的FirewallD概念。 必要條件 在開始本教程之前,請確保使用具有sudo許可權的使用者帳戶或root使用者登入伺服器。最佳做法是將管理命

CentOS7防火牆簡單命令

CentOS7中防火牆簡單命令 1、檢視防火牆狀態 firewall-cmd --state running 執行狀態 not running 關閉狀態 2、開啟防火牆 systemctl start firewalld.service 3、關閉防火牆 systemctl

Centos75 firewalld防火牆

Centos75 防火牆iptables被firewalld取代   #啟動firewalld systemctl start firewalld #檢視firewalld systemctl status firewalld #停止firewalld systemctl s

centos7 關閉防火牆命令

CentOS 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆步驟。 1、關閉firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止f

CentOS7.3防火牆設定

1、檢視firewall服務狀態    systemctl status firewalld 2、檢視firewall的狀態    firewall-cmd --state 3、開啟、重啟、關閉、firewalld.service服務 # 開啟 service

centos7 操作防火牆

原文:https://blog.csdn.net/u012498149/article/details/78772058    1、firewalld的基本使用 啟動: systemctl start firewalld 檢視狀態: systemctl status firewal

Linux CentOS7 設定防火牆使apache及mysql可以被外部訪問

1、關閉firewall # systemctl stop firewalld.service 2、禁止firewall開機啟動 # systemctl disable firewalld.service 3、安裝iptables防火牆 # yum install -

centos7防火牆設定

官方文件: https://access.redhat.com/documentation/en-us/red_hat_enterprise_linux/7/html/security_guide/sec-using_firewalls#sec-Introduction_to_firewalld

firewalld 防火牆配置

1. firewalld-cmd 命令中使用的引數以及作用  --get-default-zone 查詢預設的區域名稱 --set-default-zone=<區域名稱> 設定預設的區域,使其永久生效 --get-zones 顯示可用的區域 --get-services 顯示預先定義的服

Centos7.3防火牆配置

1、檢視firewall服務狀態 systemctl status firewalld 2、檢視firewall的狀態 firewall-cmd --state 3、開啟、重啟、關閉、f

centos6和centos7防火牆的操作

1:centos6的兩種方式 1.1:service方式 檢視防火牆狀態: [[email protected] ~]# service iptables status iptables:未執行防火牆。 開啟防火牆: [[email protected] ~]# service

Firewalld防火牆設定

Firewalld防火牆 1. firewalld的基本命令 啟動: systemctl start firewalld 關閉: systemctl stop firewalld 檢視狀態: syste