【发布时间】:2020-09-11 13:08:02
【问题描述】:
我有一台运行 CentOS 7 的谷歌计算机,我编写了一个快速测试来尝试通过端口 9000(从我的家用 PC)与它通信 - 但我出乎意料地遇到网络错误。
我的测试脚本(尝试发送有效负载)和 plink.exe(我只是用来检查端口可用性)都会发生这种情况。
>plink.exe -v -raw -P 9000 <external_IP>
Connecting to <external_IP> port 9000
Failed to connect to <external_IP>: Network error: Connection refused
Network error: Connection refused
FATAL ERROR: Network error: Connection refused
我已将外部 IP 添加到 google 防火墙 (https://console.cloud.google.com/networking/firewalls) 并设置为允许通过端口 9000 的入口流量(这是最低优先级,为 1000)
我还在 CentOS 中更新了 firewalld 以允许 TCP 流量通过端口:
Redirecting to /bin/systemctl start firewalld.service
[foo@bar ~]$ sudo firewall-cmd --zone=public --add-port=9000/tcp --permanent
success
[foo@bar ~]$ sudo firewall-cmd --reload
success
- 我已确认我的侦听器正在端口 9000 上运行
[foo@bar ~]$ netstat -npae | grep 9000
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp 0 0 127.0.0.1:9000 0.0.0.0:* LISTEN 1000 18381 1201/python3
- 默认情况下,CentOS 7 不使用 iptables(只是为了确定,我确认它没有运行)
我错过了什么吗?
注意:实际外部 IP 替换为 <external_IP> 占位符
更新: 如果我通过本地 IP(如 127.0.0.1)从 CentOS 7 计算实例的端口 9000 上映射我的侦听器,我会得到一些结果。有趣的是,如果我对服务器的外部 IP 进行相同的 nmap 调用——nadda。所以这一定是防火墙,对吧?
外部调用
[foo@bar~]$ nmap <external_IP> -Pn
Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-25 00:33 UTC
Nmap scan report for <external_IP>.bc.googleusercontent.com (<external_IP>)
Host is up (0.00043s latency).
Not shown: 998 filtered ports
PORT STATE SERVICE
22/tcp open ssh
3389/tcp closed ms-wbt-server
Nmap done: 1 IP address (1 host up) scanned in 4.87 seconds
内部调用
[foo@bar~]$ nmap 127.0.0.1 -Pn
Starting Nmap 6.40 ( http://nmap.org ) at 2020-05-25 04:36 UTC
Nmap scan report for localhost (127.0.0.1)
Host is up (0.010s latency).
Not shown: 997 closed ports
PORT STATE SERVICE
22/tcp open ssh
25/tcp open smtp
9000/tcp open cslistener
Nmap done: 1 IP address (1 host up) scanned in 0.10 seconds
【问题讨论】:
标签: networking google-compute-engine centos7 firewall google-cloud-networking