CentOS 7 0 配置防火牆

2021-08-13 10:20:29 字數 2611 閱讀 7343

1.centos 7.2

解決centos採用firewalld來管理防火牆,棄用iptables的解決辦法

使用firewalld來開放埠,對防火牆的簡單操作

1.停止iptables服務

systemctl stop iptables.service
2.啟動 firewalld服務

systemctl start firewalld.service
這時候可能出現錯誤

failed to start firewalld.service: unit firewalld.service is masked.

在網上找到解決辦法是

systemctl unmask firewalld.service
3.啟動 firewalld.service

systemctl start firewalld.service
4.把 8080 埠新增到防火牆開放埠中

firewall

-cmd--

permanent--

zone=public--

add-

port=8080/tcp

5.重啟一遍 firewalld 服務使其生效

systemctl restart firewalld.service
6.檢查更改是否生效

firewall-cmd

--zone=

public

--query-port

=80/tcp

7.其他的防火牆的一些操作

1、firewalld的基本使用

啟動: systemctl start firewalld

檢視狀態: systemctl status firewalld

停止: systemctl disable firewalld

禁用: systemctl stop 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-inte***ce

=eth0

拒絕所有包:firewall-cmd

--panic-on

取消拒絕狀態: firewall-cmd

--panic-off

檢視是否拒絕: firewall-cmd

--query-panic

那怎麼開啟乙個埠呢

新增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

CentOS 7 0如何配置防火牆

在虛擬機器中安裝了centos,然後啟動個web服務,想從本地機器訪問怎麼辦?安裝它,只需 yum install firewalld 如果需要圖形介面的話,則再安裝 yum install firewall config 一 介紹 防火牆守護 firewalld 服務引入了乙個信任級別的概念來管理...

CentOS 7 0防火牆設定

作業系統環境 centos linux release 7.0.1406 core 64位 centos 7.0預設使用的是firewall作為防火牆,這裡改為iptables防火牆步驟。1 關閉firewall systemctl stop firewalld.service 停止firewall...

CentOS7 0以上版本linux防火牆問題

centos 7.0預設使用的是firewall作為防火牆,使用iptables來做防火牆,那麼必須重新設定一下 1 直接關閉防火牆 systemctl stop firewalld.service 停止firewall systemctl disable firewalld.service 禁止f...