在CentOS系统中,您可以使用firewalld
或iptables
来设置防火墙
方法1:使用firewalld
sudo yum install firewalld
sudo systemctl start firewalld
sudo systemctl enable firewalld
sudo firewall-cmd --state
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
sudo firewall-cmd --reload
sudo firewall-cmd --list-all
方法2:使用iptables
sudo yum install iptables
sudo systemctl start iptables
sudo systemctl enable iptables
sudo iptables -L
sudo iptables -A INPUT -p tcp --dport 80 -j ACCEPT
sudo service iptables save
sudo iptables -L
以上就是在CentOS服务器上设置防火墙的方法。请注意,根据您的需求,您可能需要根据实际情况调整这些命令。
亿速云「云服务器」,即开即用、新一代英特尔至强铂金CPU、三副本存储NVMe SSD云盘,价格低至29元/月。点击查看>>
推荐阅读:CentOS SFTP服务器防火墙设置