本文轉自:https://blog.csdn.net/tengqingyong/article/details/82805053
一 :阿里雲centos7.x用iptables打開80端口
1、安裝iptables:yum install iptables-services(阿里雲centos7 默認 是使用的firewall,所以要使用iptables需先安裝)
2、相看filrwall是否關閉:
查看:systemctl status firewalld
啟動: systemctl start firewalld
關閉: systemctl stop firewalld
開機禁用 : systemctl disable firewalld
開機啟用 : systemctl enable firewalld
3、把端口加入到iptables中(加入之前,可使用iptables -L -n查看端口情況)
指令:vim /etc/sysconfig/iptables
4、重啟iptables:systemctl restart iptables.service(重啟后,使用 iptables -L -n查看)
二:centos7.x用firewall打開80端口
1.關閉與開啟防火牆
啟動:systemctl start firewalld
關閉: systemctl stop firewalld
2.查看防火牆是否開啟的狀態,以及開放端口的情況
systemctl status firewalld.service
firewall-cmd --list-all
3. 通過以下命令開放http 80 端口
firewall-cmd --add-port=80/tcp --permanent
命令末尾的--permanent表示用久有效,不加這句的話重啟后剛才開放的端口就又失效了
4 .然后重啟防火牆:
sudo firewall-cmd --reload
5. 再次查看端口的開放情況:
firewall-cmd --list-all
ports:里出現了 80 端口
三 OK后,還需在阿里雲控制台上, 添加安全組規則。