Centos7:linux
CentOS升級到7以後,發現沒法使用iptables控制Linuxs的端口,google以後發現Centos 7使用firewalld代替了原來的iptables。下面記錄如何使用firewalld開放Linux端口:tcp
使用命令的方式配置CentOS7防火牆google
##Add
firewall-cmd --permanent --zone=public --add-port=80/tcp
##Remove
firewall-cmd --permanent --zone=public --remove-port=80/tcp
##Reload
firewall-cmd --reload.net
檢查是否生效rest
firewall-cmd --zone=public --query-port=80/tcpip
列出全部的開放端口rem
firewall-cmd --list-allget
查看防火牆狀態cmd
systemctl status firewalld.servicetable
啓動防火牆
systemctl start firewalld.service
關閉防火牆
systemctl stop firewalld.service
從新啓動防火牆
systemctl restart firewalld.service
如:
[caibo@localhost /]$ firewall-cmd --zone=public --add-port=3306/tcp --permanent
success
[caibo@localhost /]$ firewall-cmd --reload
systemctl stop firewalld.service #中止 systemctl disable firewalld.service #禁用