1. Run the command
firewall-cmd --get-active-zones
Here you can see the name of the zone
2. Run to open port
Here I want to open port is 8090, if you want to open a different port, automatically change the port name.
firewall-cmd --zone=public --add-port=3306/tcp --permanent
Command Meaning:
--zone # Scope
--add-port = 80 / tcp # Add port, the format is: port / protocol
--permanent # permanent, this parameter does not restart after failure
3. Restart the firewall
End open port is required to restart the firewall
firewall-cmd --reload
4. Check whether to open
method one
firewall-cmd --query-port=8090/tcp
Yes means the emergence of a successful open
Method Two:
firewall-cmd --list-ports
Below you can see the port number you open.
Here, open port on the end of the tutorial
tips:
firewall-cmd --reload #重启firewall
systemctl stop firewalld.service #停止firewall
systemctl disable firewalld.service #禁止firewall开机启动
firewall-cmd --state #查看默认防火墙状态(关闭后显示notrunning,开启后显示running)