Öffnen Sie einen Port unter Ubuntu 14.04

Öffnen Sie einen Port unter Ubuntu 14.04

Ich habe ähnliche Threads gesehen, aber sie haben mir nicht geholfen.

Ich verwende Ubuntu 14.04.2 LTS (GNU/Linux 2.6.32-042stab108.5 x86_64) auf meinem VPS.

Ich habe eine Node.js-Anwendung auf Port 9000 ausgeführt, aber dieser Port ist geschlossen, sodass ich meine Webseite nicht mit einem Webbrowser über das Internet sehen kann.

Meine geöffneten Ports:

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

Ich habe versucht, die folgenden Befehle auszuführen:

sudo iptables -I INPUT -p tcp -m tcp --dport 9000 -j ACCEPT
sudo iptables -A INPUT -p tcp --dport 9000 -j ACCEPT

Aber es hat mir nicht geholfen. Außerdem fehlt die Datei /etc/iptables.rules, sodass ich die Änderungen mit dem folgenden Befehl nicht speichern konnte: iptables-save > /etc/iptables.rules

Können Sie mir bitte helfen? Danke.

Antwort1

Probieren Sie es aus

sudo iptables -I INPUT -p tcp -s 0.0.0.0/0 --dport 9000 -j ACCEPT

Um die Änderung dauerhaft zu machen

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

OriginalQuelle

Antwort2

port 9000Wenn der Befehl netstatin Ihrer App nicht angezeigt wird, listeningläuft er nicht oder besser gesagt, Ihr Server erwartet keine Verbindung über diesen Port.

verwandte Informationen