臨時永久關閉
#臨時關閉
systemctl stop firewalld
#永久關閉,即設置開機的時候不自動啓動
systemctl disable firewalld
添加刪除端口
#添加
firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,沒有此參數重啓後失效)
#重新載入
firewall-cmd --reload
#查看
firewall-cmd --zone= public --query-port=80/tcp
#刪除
firewall-cmd --zone= public --remove-port=80/tcp --permanent
添加一個服務到firewalld
firewall-cmd --add-service=http //http換成想要開放的service
如果要添加的端口並沒有服務對應,就要新建一個服務,在/usr/lib/firewalld/services,隨便拷貝一個xml文件到一個新名字,比如myservice.xml,把裏面的
<?xml version="1.0" encoding="utf-8"?>
<service>
<short>Transmission-client</short>
<description>Transmission is a lightweight GTK+ BitTorrent client.</description>
<port protocol="tcp" port="51413"/>
</service>
然後把新建的service添加到firewalld
firewall-cmd --permanent --add-service=myservice