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ī)則,重啟服務: 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: 丟棄所有進入的包,而不給出任何響應
block: 拒絕所有外部發(fā)起的連接,允許內(nèi)部發(fā)起的連接
public: 允許指定的進入連接
external: 同上,對偽裝的進入連接,一般用于路由轉(zhuǎn)發(fā)
dmz: 允許受限制的進入連接
work: 允許受信任的計算機被限制的進入連接,類似 workgroup
home: 同上,類似 homegroup
internal: 同上,范圍針對所有互聯(lián)網(wǎng)用戶
trusted: 信任所有連接
4.firewall開啟和關閉端口
以下都是指在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.管理服務
以smtp服務為例, 添加到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
關閉: 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的服務管理工具中主要的工具,它融合之前service和chkconfig的功能于一體。
啟動一個服務:systemctl start firewalld.service
關閉一個服務: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
總結(jié)
到此這篇關于CentOS7 防火墻(firewall)的操作命令大全的文章就介紹到這了,更多相關CentOS防火墻操作命令內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關文章希望大家以后多多支持腳本之家!
相關文章
CentOS6.3添加nginx系統(tǒng)服務的實例詳解
這篇文章主要介紹了CentOS6.3添加nginx系統(tǒng)服務的實例詳解的相關資料,希望通過本文能幫助到大家,讓大家掌握這部分內(nèi)容,需要的朋友可以參考下2017-10-10CentOS 6.4安裝配置LAMP服務器(Apache+PHP5+MySQL)
這篇文章主要介紹了CentOS 6.4安裝配置LAMP服務器(Apache+PHP5+MySQL)的方法,需要的朋友可以參考下2013-06-06