1. 程式人生 > 其它 >linux防火牆策略

linux防火牆策略

檢視防火牆狀態

[root@localhost ~]# systemctl status firewalld.service    #檢視防火牆狀態(執行中)
[root@localhost ~]# systemctl stop firewalld.service    #關閉防火牆
[root@localhost ~]# systemctl disable firewalld.service   #禁止使用防火牆(重啟也是禁止的) 如果是內網無所謂,如果是阿里雲或者其他雲建議不要這樣做,開啟防火牆策略即可
檢查防火牆策略
[root@localhost ~]# firewall-cmd --list-all
將需要永久開放的埠加入防火牆
[root@localhost ~]# sudo firewall-cmd --zone=public --add-port=7001/tcp --permanent
重新載入防火牆
[root@localhost ~]# sudo firewall-cmd --reload # 重新載入完成後,再通過 firewall-cmd --list-all 命令檢視防火牆的規則,埠已經加入進去
其他常用命令
[root@localhost ~]# systemctl restart firewalld
#檢查防火牆狀態
[root@localhost ~]# firewall-cmd --state
[root@localhost ~]# firewall-cmd --list-all
#Disable firewall
[root@localhost ~]# systemctl disable firewalld
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl status firewalld
#Enable firewall
[root@localhost ~]# systemctl enable firewalld
[root@localhost ~]# systemctl start firewalld
[root@localhost ~]# systemctl status firewalld