富贵资源网 Design By www.hznty.com

一句话:如果你是买的各大厂商的云服务器,去安全组配置对应需要使用到的端口就可以啦!

因为博主用的是阿里云,所以这里就只介绍下阿里云如何开放端口,按着下面三张图来操作就行嘞

阿里云Centos7.X 如何对外开放端口的方法步骤

阿里云Centos7.X 如何对外开放端口的方法步骤

阿里云Centos7.X 如何对外开放端口的方法步骤

这个时候有同学就说了,不通过平台的方式行不行,我想锻炼我的Linux能力...当然可以,接下来介绍下直接在Linux上配置防火墙规则来开放端口(Centos7以上,Centos6和7用的防火墙规则不一样,这里不介绍Centos6)

先掌握下systemctl+firewall命令

描述 命令 查看firewall状态 systemctl status firewalld.service 启动firewall systemctl start firewalld 停止firewall systemctl stop firewalld 开机启动firewall systemctl enable firewalld 开机禁止firewall systemctl disable firewalld 额外学习下systemctl命令^_^ 查看服务是否开机启动 systemctl is-enabled firewalld.service 查看已启动的服务列表 systemctl list-unit-files|grep enabled 查看启动失败的服务列表 systemctl --failed

其次掌握firewall-cmd命令

描述 命令 查看firewall全部信息 firewall-cmd --list-all 查看已开放的端口 firewall-cmd --list-ports 更新防火墙规则 firewall-cmd --reload 开放端口 firewall-cmd --zone=public --add-port=3000/tcp --permanent 关闭端口 firewall-cmd --zone=public --remove-port=3000/tcp --permanent

最终执行步骤:

  1. 首先查看firewall是否已开启: systemctl status firewalld.service
  2. 开放端口(开放后需要更新规则才能生效):  firewall-cmd --zone=public --add-port=3000/tcp --permanent
  3. 更新防火墙规则: firewall-cmd --reload

阿里云Centos7.X 如何对外开放端口的方法步骤

富贵资源网 Design By www.hznty.com
广告合作:本站广告合作请联系QQ:858582 申请时备注:广告合作(否则不回)
免责声明:本站资源来自互联网收集,仅供用于学习和交流,请遵循相关法律法规,本站一切资源不代表本站立场,如有侵权、后门、不妥请联系本站删除!
富贵资源网 Design By www.hznty.com