centos7 firewall 防火牆常用命令

2021-10-12 04:19:03 字數 1162 閱讀 5622

centos7 使用的防火牆是 firewalld

yum install firewalld
# 開啟服務

systemctl start firewalld

# 關閉防火牆

systemctl stop firewalld

# 檢視啟動狀態

systemctl status firewalld

# 開機自動啟動

systemctl enable firewalld

# 關閉開機制動啟動

systemctl disable firewalld

firewall-cmd --list-all --permanent
firewall-cmd --reload
–zone=public,不加的話會用預設的 zone,下文有查詢預設 zone 的命令

firewall-cmd --zone=public --query-port=8080/tcp
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --permanent --remove-port=8080/tcp
firewall-cmd --permanent --zone=public --add-port=8080-8081/tcp
# 相當於開啟了 80/tcp 埠

# 相當於開啟了 443/tcp 埠

firewall-cmd --zone=public --add-service=https

firewall-cmd --runtime-to-permanent
firewall-cmd --get-default-zone
firewall-cmd --set-default-zone=public
這個文章總結的挺好的

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