无法从远程计算机连接到 Ubuntu

无法从远程计算机连接到 Ubuntu

在我的 Ubuntu 中,我安装了 tomcat 并部署了 web 应用程序。我启动了 tomcat 并尝试从 windows 访问,如下所示:

http://<54.85.125.1:8080>/manager

我得到如下输出:

could not connect to 54.85.125.1:8080

然后我执行sudo ufw enable命令,在 Ubuntu 中启用防火墙,但即使如此,我仍然无法连接到远程机器。

有人请帮助我

我在 cmd 中执行了 netstat -a

    ubuntu@ip-172-31-20-201:~$ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State
tcp        0      0 *:ssh                   *:*                     LISTEN
tcp        0      0 *:http                  *:*                     LISTEN
tcp        0      0 ip-172-31-20-201.ec:ssh mail.pagesolution:18414 ESTABLISHED
tcp        0      0 ip-172-31-20-201.ec:ssh mail.pagesolution:64067 ESTABLISHED
tcp        0      0 ip-172-31-20-201.:58381 ec2-54-186-216-161:4505 ESTABLISHED
tcp        0    320 ip-172-31-20-201.ec:ssh mail.pagesolution:18178 ESTABLISHED
tcp        0      0 ip-172-31-20-201.ec:ssh mail.pagesolution:64065 ESTABLISHED
tcp6       0      0 [::]:ssh                [::]:*                  LISTEN
tcp6       0      0 [::]:8009               [::]:*                  LISTEN
tcp6       0      0 [::]:http-alt           [::]:*                  LISTEN
tcp6       0      0 localhost:http-alt      localhost:43938         TIME_WAIT
tcp6       0      0 ip6-localhost:51788     ip6-localhost:52644     TIME_WAIT
tcp6       0      0 ip6-localhost:57361     ip6-localhost:57173     TIME_WAIT
tcp6       0      0 localhost:8009          localhost:39078         TIME_WAIT
tcp6       0      0 localhost:49296         localhost:8005          TIME_WAIT
udp        0      0 *:bootpc                *:*
Active UNIX domain sockets (servers and established)
Proto RefCnt Flags       Type       State         I-Node   Path
unix  2      [ ACC ]     STREAM     LISTENING     7432     /var/run/acpid.socket
unix  2      [ ACC ]     STREAM     LISTENING     5867     @/com/ubuntu/upstart
unix  2      [ ACC ]     STREAM     LISTENING     7250     /var/run/dbus/system_bus_socket
unix  8      [ ]         DGRAM                    7299     /dev/log
unix  2      [ ACC ]     SEQPACKET  LISTENING     6070     /run/udev/control
unix  2      [ ACC ]     STREAM     LISTENING     58324    /var/run/salt/minion/minion_event_0419609a49f1eec5f4394428f9cebbb5_pub.ipc
unix  2      [ ACC ]     STREAM     LISTENING     58326    /var/run/salt/minion/minion_event_0419609a49f1eec5f4394428f9cebbb5_pull.ipc
unix  3      [ ]         STREAM     CONNECTED     126113
unix  3      [ ]         STREAM     CONNECTED     126112
unix  3      [ ]         STREAM     CONNECTED     126092
unix  3      [ ]         STREAM     CONNECTED     126091
unix  2      [ ]         DGRAM                    125836
unix  2      [ ]         DGRAM                    125830
unix  3      [ ]         STREAM     CONNECTED     123313
unix  3      [ ]         STREAM     CONNECTED     123312
unix  2      [ ]         DGRAM                    123174
unix  3      [ ]         STREAM     CONNECTED     121839
unix  3      [ ]         STREAM     CONNECTED     121838
unix  2      [ ]         DGRAM                    121700
unix  2      [ ]         DGRAM                    11061
unix  3      [ ]         STREAM     CONNECTED     7570     /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     7569
unix  2      [ ]         DGRAM                    7418
unix  3      [ ]         STREAM     CONNECTED     7276     /var/run/dbus/system_bus_socket
unix  3      [ ]         STREAM     CONNECTED     7275
unix  3      [ ]         STREAM     CONNECTED     7274
unix  3      [ ]         STREAM     CONNECTED     7273
unix  3      [ ]         STREAM     CONNECTED     6557     @/com/ubuntu/upstart
unix  3      [ ]         STREAM     CONNECTED     6556
unix  3      [ ]         DGRAM                    6110
unix  3      [ ]         DGRAM                    6109
unix  3      [ ]         STREAM     CONNECTED     6045     @/com/ubuntu/upstart
unix  3      [ ]         STREAM     CONNECTED     6042

并在 ubuntu 中执行 ps -ax

ubuntu@ip-172-31-20-201:~$ ps -ax

4479 ?        S      0:00 /usr/sbin/apache2 -k start
 4480 ?        S      0:00 /usr/sbin/apache2 -k start
 4481 ?        S      0:00 /usr/sbin/apache2 -k start
 4487 ?        S      0:00 /usr/sbin/apache2 -k start
 4579 ?        S      0:00 /usr/sbin/apache2 -k start
17348 ?        Ss     0:17 /usr/sbin/apache2 -k start

并在 ubuntu 中执行了 telnet localhost 8080

ubuntu@ip-172-31-20-201:~$ telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

我没有任何类似 /etc/init.d/tomcatX restart 的文件。我像下面这样启动服务器。

ubuntu@ip-172-31-20-201:~$ sudo /opt/apache-tomcat-7.0.53/bin/startup.sh
Using CATALINA_BASE:   /opt/apache-tomcat-7.0.53
Using CATALINA_HOME:   /opt/apache-tomcat-7.0.53
Using CATALINA_TMPDIR: /opt/apache-tomcat-7.0.53/temp
Using JRE_HOME:        /usr
Using CLASSPATH:       /opt/apache-tomcat-7.0.53/bin/bootstrap.jar:/opt/apache-tomcat-7.0.53/bin/tomcat-juli.jar
Tomcat started.

答案1

不允许 Ping。当我扫描端口时

xxx@xxx ~$ sudo nmap 54.85.125.1 -P0

Starting Nmap 6.40 ( http://nmap.org ) at 2014-04-15 12:13 CEST
Nmap scan report for ec2-54-85-125-1.compute-1.amazonaws.com (54.85.125.1)
Host is up (0.11s latency).
Not shown: 999 filtered ports
PORT   STATE SERVICE
22/tcp open  ssh

Nmap done: 1 IP address (1 host up) scanned in 21.42 seconds

我看到只有端口 22 是开放的。如果您的服务需要连接,则必须处于监听状态,您可以使用命令检查这一点netstat -a

输出示例如下:

xxx@xxx ~ $ netstat -a
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address           Foreign Address         State      
tcp        0      0 *:ssh                   *:*                     LISTEN     
tcp        0      0 *:ipp                   *:*                     LISTEN     
tcp        0      0 *:15096                 *:*                     LISTEN 

如果没有处于监听状态的服务,请尝试ps -ax查看服务是否正在运行。您也可以通过 ssh 连接到服务器,然后尝试telnet localhost 8080查看是否可以连接到 tomcat。

相关内容