Linux Spring boot 2.1在Ubuntu18.4上运行,但无法从外部连接
我的主计算机是Windows10。 我正在尝试在VM Ubuntu18.04上执行我的spring boot项目。 在Ubuntu中,我可以连接我的spring boot项目Linux Spring boot 2.1在Ubuntu18.4上运行,但无法从外部连接,linux,spring-boot,ubuntu,networking,Linux,Spring Boot,Ubuntu,Networking,我的主计算机是Windows10。 我正在尝试在VM Ubuntu18.04上执行我的spring boot项目。 在Ubuntu中,我可以连接我的spring boot项目 root@ubuntu:~# netstat -tnlp Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Progra
root@ubuntu:~# netstat -tnlp
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name
tcp 0 0 127.0.0.53:53 0.0.0.0:* LISTEN 691/systemd-resolve
tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 909/sshd
tcp6 0 0 127.0.0.1:8080 :::* LISTEN 8513/java
tcp6 0 0 :::22 :::* LISTEN 909/sshd
你的浏览器是在虚拟机上运行还是在Windows上运行?我的浏览器是在Windows上运行。因此,你必须弄清楚虚拟机的IP地址是多少,在Ubuntu上使用NAT(仅主机)设置静态IP。我可以在Windows上使用ssh访问Ubuntu(192.168.56.103)。但是我无法在Windows上连接运行在VM Ubuntu上的web服务。如何运行该应用程序?您可以尝试用java-jar.jar-Dserver.address=0.0.0.0启动它吗
root@ubuntu:~# curl localhost:8080
<!doctype html>
<html lang="en">
<head>
...
root@ubuntu:~# ifconfig
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.56.103 netmask 255.255.255.0 broadcast 192.168.56.255
inet6 fe80::a00:27ff:fe9b:9f58 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:9b:9f:58 txqueuelen 1000 (Ethernet)
RX packets 337554 bytes 470268104 (470.2 MB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 32494 bytes 6910341 (6.9 MB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
server:
port: 8080
address: 0.0.0.0