詳解CentOS7使用firewalld打開關(guān)閉防火墻與端口
1、firewalld的基本使用
啟動:
systemctl start firewalld
查看狀態(tài):
systemctl status firewalld
停止:
systemctl disable firewalld
禁用:
systemctl stop firewalld
2.systemctl是CentOS7的服務管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。
啟動一個服務:
systemctl start firewalld.service
關(guān)閉一個服務:
systemctl stop firewalld.service
重啟一個服務:
systemctl restart firewalld.service
顯示一個服務的狀態(tài):
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
顯示狀態(tài):
firewall-cmd --state
查看所有打開的端口:
firewall-cmd --zone=public --list-ports
更新防火墻規(guī)則:
firewall-cmd --reload
查看區(qū)域信息:
firewall-cmd --get-active-zones
查看指定接口所屬區(qū)域:
firewall-cmd --get-zone-of-interface=eth0
拒絕所有包:
firewall-cmd --panic-on
取消拒絕狀態(tài):
firewall-cmd --panic-off
查看是否拒絕:
firewall-cmd --query-panic
那怎么開啟一個端口呢
添加
firewall-cmd --zone=public --add-port=80/tcp --permanent
(--permanent永久生效,沒有此參數(shù)重啟后失效)
重新載入
firewall-cmd --reload
查看
firewall-cmd --zone= public --query-port=80/tcp
刪除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
以上就是本文的全部內(nèi)容,希望對大家的學習有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
Linux基礎:如何找出你的系統(tǒng)所支持的最大內(nèi)存
這篇文章主要介紹了Linux基礎:如何找出你的系統(tǒng)所支持的最大內(nèi)存,需要的朋友可以參考下2015-04-04解決Centos7 安裝騰達U12無線網(wǎng)卡驅(qū)動問題
這篇文章主要介紹了Centos7 安裝騰達U12無線網(wǎng)卡驅(qū)動,本文給出了解決過程,通過兩種方法給大家介紹的非常詳細,具有一定的參考借鑒價值,需要的朋友可以參考下2019-10-10linxu服務器上nginx啟動、關(guān)閉、配置檢查命令(推薦)
這篇文章主要介紹了linxu服務器上nginx啟動、關(guān)閉、配置檢查命令,文章內(nèi)容比較簡單,具有一定的參考借鑒價值,需要的朋友可以參考下2018-07-07基于linux配置selenium環(huán)境并實現(xiàn)運行
這篇文章主要介紹了基于linux配置selenium環(huán)境并實現(xiàn)運行,文中通過示例代碼介紹的非常詳細,對大家的學習或者工作具有一定的參考學習價值,需要的朋友可以參考下2020-08-08