https://www.cnblogs.com/bigfly277/p/11193829.html
centos7 open the firewall and the specified port
1, open the firewall
- First check firewall status:
firewall-cmd --state
- Open the firewall
systemctl start firewalld.service
- Set the boot from the start:
systemctl enable firewalld.service
- Restart the firewall:
systemctl restart firewalld.service
- Check whether the firewall state open:
firewall-cmd --state
- Check the firewall settings to boot from the start is successful:
systemctl is-enabled firewalld.service;echo $?
2, open port
开端口命令:firewall-cmd --zone=public --add-port=80/tcp --permanent
重启防火墙:systemctl restart firewalld.service
查看开启的所有端口:firewall-cmd --list-ports
命令含义:
--zone #作用域
--add-port=80/tcp #添加端口,格式为:端口/通讯协议
--permanent #永久生效,没有此参数重启后失效