Centos7 Firewall 防火牆命令

2022-08-12 05:36:17 字數 1477 閱讀 7155

centos7預設安裝了firewalld,如果沒有安裝的話,則需要yum命令安裝;firewalld真的用不習慣,與之前的iptable防火牆區別太大,但畢竟是未來主流講究慢慢磨合它的設定規則,需要的朋友可以參考下

1、安裝firewall命令:

yum install firewalld firewalld-config

2、firewall開啟常見埠命令:

firewall-cmd --zone=public --add-port=80/tcp --permanent

firewall-cmd --zone=public --add-port=443/tcp --permanent

firewall-cmd --zone=public --add-port=22/tcp --permanent

firewall-cmd --zone=public --add-port=21/tcp --permanent

firewall-cmd --zone=public --add-port=53/udp --permanent

3、firewall關閉常見埠命令:

firewall-cmd --zone=public --remove-port=80/tcp --permanent

firewall-cmd --zone=public --remove-port=443/tcp --permanent

firewall-cmd --zone=public --remove-port=22/tcp --permanent

firewall-cmd --zone=public --remove-port=21/tcp --permanent

firewall-cmd --zone=public --remove-port=53/udp --permanent

4、批量新增區間埠

firewall-cmd --zone=public --add-port=4400-4600/udp --permanent

firewall-cmd --zone=public --add-port=4400-4600/tcp --permanent

5、開啟防火牆命令:

systemctl start firewalld.service

6、重啟防火牆命令:

firewall-cmd --reload  或者   service firewalld restart

7、檢視埠列表:

firewall-cmd --permanent --list-port

8、禁用防火牆

systemctl stop firewalld

9、設定開機啟動

systemctl enable firewalld

10、停止並禁用開機啟動

sytemctl disable firewalld

11、檢視狀態

systemctl status firewalld或者 firewall-cmd --state

centos 7 firewall無法啟動

報錯資訊 root localhost bin systemctl status firewalld firewalld.service firewalld dynamic firewall daemon loaded loaded usr lib systemd system firewalld....

CentOS 7 firewall使用方法

1.在firewall規則中新增80埠 firewall cmd zone public add port 80 tcp permanent 2.獲取firewall狀態資訊 firewall cmd state firewall cmd reload 不改變狀態 firewall cmd comp...

centos7 firewall指定IP與埠訪問

1 啟動防火牆 systemctl start firewalld.service 2 指定ip與埠 firewall cmd permanent add rich rule rule family ipv4 source address 192.168.142.166 port protocol ...