CentOS7 firewalld相關命令

2021-08-22 18:10:14 字數 943 閱讀 7442

1、firewalld的基本使用

安裝防火牆:yum install firewalld systemd -y

啟動: systemctl start firewalld

關閉: systemctl stop firewalld

檢視狀態: systemctl status firewalld 

firewall-cmd --state

開機禁用  : systemctl disable firewalld

開機啟用  : systemctl enable firewalld

2、開啟關閉埠

單個新增

firewall-cmd --zone=public --add-port=80/tcp --permanent
批量新增 

firewall-cmd --zone=public --add-port=100-500/tcp --permanent

firewall-cmd --zone=public --add-port=100-500/udp --permanent

(--permanent永久生效,沒有此引數重啟後失效)

重新載入

firewall-cmd --reload
檢視

firewall-cmd --zone=public --query-port=80/tcp
檢視已開放埠

firewall-cmd --list-ports
刪除

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

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 ...