我见过类似的线程,但它们没有帮助我。
我在我的 VPS 上使用 Ubuntu 14.04.2 LTS (GNU/Linux 2.6.32-042stab108.5 x86_64)。
我在端口 9000 上运行了一个 node.js 应用程序,但此端口已关闭,因此我无法通过 Internet 使用 Web 浏览器查看我的网页。
我打开的端口:
sudo netstat -ntlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 752/apache2
tcp 0 0 0.0.0.0:21 0.0.0.0:* LISTEN 366/vsftpd
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 454/sshd
tcp 0 0 0.0.0.0:25 0.0.0.0:* LISTEN 611/master
tcp 0 0 127.0.0.1:27017 0.0.0.0:* LISTEN 485/mongod
tcp 0 0 127.0.0.1:3306 0.0.0.0:* LISTEN 599/mysqld
tcp6 0 0 :::22 :::* LISTEN 454/sshd
tcp6 0 0 :::25 :::* LISTEN 611/master
Run Code Online (Sandbox Code Playgroud)
我试图执行以下命令:
sudo iptables -I INPUT -p tcp -m tcp --dport 9000 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9000 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)
但这对我没有帮助。此外,/etc/iptables.rules 文件丢失,因此我无法使用以下命令保存更改:iptables-save > /etc/iptables.rules
请问你能帮帮我吗?谢谢。
试试这个
sudo iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 9000 -j ACCEPT
Run Code Online (Sandbox Code Playgroud)
使更改永久化
iptables-save > /etc/iptables.conf # Save this changes to file
touch /etc/network/if-up.d/iptables # Create file to call conf from
echo "iptables-restore < /etc/iptables.conf" >> /etc/network/if-up.d/iptables # Add this line to this file
chmod +x /etc/network/if-up.d/iptables # Make the script executable
Run Code Online (Sandbox Code Playgroud)
原始来源
| 归档时间: |
|
| 查看次数: |
65780 次 |
| 最近记录: |