一、運行、中止、禁用firewalldhtml
啓動:# systemctl start firewalldtcp
查看狀態:# systemctl status firewalld 或者 firewall-cmd --state工具
中止:# systemctl disable firewalldpost
禁用:# systemctl stop firewalld測試
systemctl status firewalld.service firewall-cmd --state
咱們尚未作任何配置,default zone和active zone都應該是publicurl
firewall-cmd --get-default-zone firewall-cmd --get-active-zones
其實一個服務對應一個端口,每一個服務對應/usr/lib/firewalld/services下面一個xml文件。spa
firewall-cmd --list-services
firewall-cmd --get-services
firewall-cmd --zone=public --list-ports
firewall-cmd --reload
firewall-cmd --add-service=http //http換成想要開放的service
這樣添加的service當前馬上生效,但系統下次啓動就失效,能夠測試使用。要永久開發一個service,加上 --permanentrest
firewall-cmd --permanent --add-service=http
就要新建一個服務,在/usr/lib/firewalld/services,隨便拷貝一個xml文件到一個新名字,好比myservice.xml,把裏面的code
<?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>
short改成想要名字(這個名字只是爲了人來閱讀,沒有實際影響。重要的是修改 protocol和port。修改完保存。個人經驗是這是要重啓firewalld服務,systemctl restart firewalld.service
,不然可能提示找不到剛纔新建的service。而後把新建的service添加到
firewalldxml
firewall-cmd --permanent --add-service=myservice
5分鐘理解Centos7防火牆firewalld http://www.cnblogs.com/stevenzeng/p/5152324.html
-------------------------------------------------------------------------------------------------------------
啓動一個服務:systemctl start firewalld.service
關閉一個服務:systemctl stop firewalld.service
重啓一個服務:systemctl restart firewalld.service
顯示一個服務的狀態:systemctl status firewalld.service
在開機時啓用一個服務:systemctl enable firewalld.service
在開機時禁用一個服務:systemctl disable firewalld.service
查看服務是否開機啓動:systemctl is-enabled firewalld.service
查看已啓動的服務列表:systemctl list-unit-files|grep enabled
查看啓動失敗的服務列表:systemctl --failed
3.配置firewalld-cmd