【发布时间】:2019-08-21 16:28:14
【问题描述】:
我是 linux 的入门级...
我让 node JS 监听 80 端口,一切正常。
但是当尝试不同的端口时它不起作用。
Firewalld is not enabled...
在浏览器中尝试时,我尝试使用 localhost:8080
有什么想法吗?
【问题讨论】:
标签: node.js linux centos centos7
我是 linux 的入门级...
我让 node JS 监听 80 端口,一切正常。
但是当尝试不同的端口时它不起作用。
Firewalld is not enabled...
在浏览器中尝试时,我尝试使用 localhost:8080
有什么想法吗?
【问题讨论】:
标签: node.js linux centos centos7
如果防火墙已经运行则停止
sudo systemctl stop firewalld
检查iptable的状态
如果尚未安装,则使用安装它
yum install iptables-services
sudo systemctl status iptables
在启动时启用服务:
systemctl enable iptables
管理服务
systemctl [stop|start|restart] iptables
保存防火墙规则的方法如下:
service iptables save
使用此命令启动和启用防火墙
sudo systemctl start firewalld
sudo systemctl enable firewalld
配置防火墙并添加要启用的IP和端口范围(可选)
firewall-cmd --add-rich-rule='rule family="ipv4" source address="10.0.0.0/8" port port="11224-12224" protocol="tcp" accept'
上面的命令获取 IP 和端口的范围。上面命令中需要替换IP和端口范围,一定要改x.x.x.x/n,这里n是端口数。
【讨论】: