由於專案運維的需要,經常需要設定linux系統的防火牆,在centos下面,使用的是firewall-cmd工具,特此記錄下一些常用的配置命令:
# 檢視防火牆服務狀態
systemctl status firewalld
# 檢視防火牆狀態
firewall-cmd --state
# 開啟防火牆
service firewalld start
# 關閉防火牆
service firewalld stop
# 重啟防火牆
service firewalld restart
# 檢視防火牆規則
firewall-cmd --list-all
# 顯示當前開放埠
firewall-cmd --list-ports
# 顯示當前開放服務
firewall-cmd --list-service
# 顯示當前rich-rules
firewall-cmd --list-rich-rules
# 修改配置後重啟防火牆生效
firewall-cmd --reload
# 查詢埠是否開放
firewall-cmd --query-port=80/tcp
# 開放埠
firewall-cmd --permanent --add-port=80/tcp
# 開放埠範圍
firewall-cmd --permanent --add-port=80-90/tcp
# 移除埠
firewall-cmd --permanent --remove-port=80/tcp
# 對指定ip開放指定埠
firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="192.168.142.166" port protocol="tcp" port="6379" accept"
# 開放服務
firewall-cmd --permanent --add-service=samba
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 ...