CentOS7?防火墻firewall的操作命令大全
安裝:
yum install firewalld
1、firewalld的基本使用
啟動: systemctl start firewalld
查看狀態(tài): systemctl status firewalld
禁用,禁止開機啟動: systemctl disable firewalld
停止運行: systemctl stop firewalld
2.配置firewalld-cmd
查看版本: firewall-cmd --version
查看幫助: firewall-cmd --help
顯示狀態(tài): firewall-cmd --state
查看所有打開的端口: firewall-cmd --zone=public --list-ports
更新防火墻規(guī)則: firewall-cmd --reload
更新防火墻規(guī)則,重啟服務(wù): firewall-cmd --completely-reload
查看已激活的Zone信息: 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
3.信任級別,通過Zone的值指定
drop: 丟棄所有進入的包,而不給出任何響應(yīng)
block: 拒絕所有外部發(fā)起的連接,允許內(nèi)部發(fā)起的連接
public: 允許指定的進入連接
external: 同上,對偽裝的進入連接,一般用于路由轉(zhuǎn)發(fā)
dmz: 允許受限制的進入連接
work: 允許受信任的計算機被限制的進入連接,類似 workgroup
home: 同上,類似 homegroup
internal: 同上,范圍針對所有互聯(lián)網(wǎng)用戶
trusted: 信任所有連接
4.firewall開啟和關(guān)閉端口
以下都是指在public的zone下的操作,不同的Zone只要改變Zone后面的值就可以
添加: 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
5.管理服務(wù)
以smtp服務(wù)為例, 添加到work zone
添加: firewall-cmd --zone=work --add-service=smtp
查看: firewall-cmd --zone=work --query-service=smtp
刪除: firewall-cmd --zone=work --remove-service=smtp
5.配置 IP 地址偽裝
查看: firewall-cmd --zone=external --query-masquerade
打開: firewall-cmd --zone=external --add-masquerade
關(guān)閉: firewall-cmd --zone=external --remove-masquerade
6.端口轉(zhuǎn)發(fā)
打開端口轉(zhuǎn)發(fā),首先需要打開IP地址偽裝 firewall-cmd --zone=external --add-masquerade
轉(zhuǎn)發(fā) tcp 22 端口至 3753: firewall-cmd --zone=external --add-forward-port=22:porto=tcp:toport=3753
轉(zhuǎn)發(fā)端口數(shù)據(jù)至另一個IP的相同端口: firewall-cmd --zone=external --add-forward-port=22:porto=tcp:toaddr=192.168.1.112
轉(zhuǎn)發(fā)端口數(shù)據(jù)至另一個IP的 3753 端口: firewall-cmd --zone=external --add-forward-port=22:porto=tcp::toport=3753:toaddr=192.168.1.112
6.systemctl是CentOS7的服務(wù)管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。
啟動一個服務(wù):systemctl start firewalld.service
關(guān)閉一個服務(wù):systemctl stop firewalld.service
重啟一個服務(wù):systemctl restart firewalld.service
顯示一個服務(wù)的狀態(tài):systemctl status firewalld.service
在開機時啟用一個服務(wù):systemctl enable firewalld.service
在開機時禁用一個服務(wù):systemctl disable firewalld.service
查看服務(wù)是否開機啟動:systemctl is-enabled firewalld.service
查看已啟動的服務(wù)列表:systemctl list-unit-files|grep enabled
查看啟動失敗的服務(wù)列表:systemctl --failed
總結(jié)
到此這篇關(guān)于CentOS7 防火墻(firewall)的操作命令大全的文章就介紹到這了,更多相關(guān)CentOS防火墻操作命令內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
linux命令行報錯bash command not found問題及解決
這篇文章主要介紹了linux命令行報錯bash command not found問題及解決,具有很好的參考價值,希望對大家有所幫助,如有錯誤或未考慮完全的地方,望不吝賜教2024-08-08
Centos7.4 zabbix3.4.7源碼安裝的方法步驟
這篇文章主要介紹了Centos7.4 zabbix3.4.7源碼安裝的方法步驟,小編覺得挺不錯的,現(xiàn)在分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2018-06-06
Apache?Kafka?分區(qū)重分配的實現(xiàn)原理解析
這篇文章主要介紹了Apache?Kafka?分區(qū)重分配的實現(xiàn)原理,本文結(jié)合?2.0.0?版本的?Kafka?源碼,詳細介紹了?Kafka?分區(qū)副本重分配的流程和邏輯,需要的朋友可以參考下2022-07-07
Ubuntu18.04 一鍵升級Python所有第三方包 及安裝python包的方法
pip 是 Python 包管理工具,該工具提供了對Python 包的查找、下載、安裝、卸載的功能。這篇文章給大家介紹Ubuntu18.04 一鍵升級Python所有第三方包 ,感興趣的朋友一起看看吧2019-10-10

