要在CentOS上设置防火墙开放端口,可以使用firewalld或iptables两种工具。
使用firewalld设置防火墙开放端口:
sudo systemctl status firewalldsudo systemctl start firewalldsudo firewall-cmd --get-servicessudo firewall-cmd --zone=public --add-port=<端口号>/tcp --permanentsudo firewall-cmd --reloadsudo firewall-cmd --list-ports使用iptables设置防火墙开放端口:
sudo systemctl status iptablessudo systemctl start iptablessudo iptables -A INPUT -p tcp --dport <端口号> -j ACCEPTsudo service iptables savesudo service iptables restartsudo iptables -L -n注意:以上命令中的"<端口号>"需要替换为要开放的具体端口号。另外,firewalld和iptables只需要选择其中一种工具进行配置即可。