
我見過類似的線程,但它們對我沒有幫助。
我在我的 VPS 上使用 Ubuntu 14.04.2 LTS (GNU/Linux 2.6.32-042stab108.5 x86_64)。
我在連接埠 9000 上運行了一個 node.js 應用程序,但該連接埠已關閉,因此我無法透過互聯網使用網路瀏覽器查看我的網頁。
我打開的連接埠:
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
我試圖執行以下命令:
sudo iptables -I INPUT -p tcp -m tcp --dport 9000 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9000 -j ACCEPT
但這對我沒有幫助。此外,/etc/iptables.rules 檔案遺失,因此我無法使用以下命令儲存變更: iptables-save > /etc/iptables.rules
請問你能幫幫我嗎?謝謝。
答案1
嘗試一下
sudo iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 9000 -j ACCEPT
使改變永久化
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
原來的來源
答案2
如果您在應用程式中沒有看到port 9000
命令未運行,或者更好的說法是,您的伺服器不希望在該連接埠上建立連線。netstat
listening