【发布时间】:2021-11-03 16:40:33
【问题描述】:
我正在尝试从 ssh 终端连接到在谷歌云平台 VM 上运行的服务。
正在运行的进程正在监听 7076,如下所示:
ced@instance-1:~$ sudo ss -ltn
State Recv-Q Send-Q Local Address:Port Peer Address:Port Process
LISTEN 0 4096 127.0.0.53%lo:53 0.0.0.0:*
LISTEN 0 128 0.0.0.0:22 0.0.0.0:*
LISTEN 0 128 [::]:22 [::]:*
LISTEN 0 1024 [::1]:7076 [::]:*
我还有以下允许内部连接的防火墙规则:
Name Type Targets Filters Protocols/ports
default-allow-internal Ingress Apply to all IP ranges: 10.128.0.0/9 tcp:0-65535, udp:0-65535
使用命令时:
curl -X POST --data '{"action": "benchmark"}' localhost:7076
回复是:
curl: (7) Failed to connect to localhost port 7076: Connection refused
据我了解:
- [::1]:7076 表示我的服务只监听本地主机上的连接
- 我通过ssh连接,然后使用curl,这是一个内部连接(即:来自本地主机)
因此我不明白为什么我无法连接。
【问题讨论】:
-
试试 curl -6 http://[::1]:7076。如果可行,那么您的应用程序仅在 IPv6 localhost 上侦听。
-
@JohnHanley 似乎是这样。您能否给出一个答案,解释如何为未来的读者和我自己发现这些?
-
您的命令 sudo ss -ltn 显示 [::1]:7076。地址 ::1 是 IPv6 localhost。
标签: curl google-cloud-platform port firewall