简体   繁体   English

在 macos mojave 上从外部访问 tcp 端口 8080

[英]Accessing tcp port 8080 externally on macos mojave

I am trying to access a listening tcp socket on my macbook from any external client on the same wi-fi lan.我正在尝试从同一 wi-fi lan 上的任何外部客户端访问我的 macbook 上的侦听 tcp 套接字。

This works for specific ports, eg.这适用于特定端口,例如。 8000, but not other ports, eg. 8000,但不是其他端口,例如。 8080, 8081, 8082 8080、8081、8082

How can I open up or access the 8080 tcp port externally?如何从外部打开或访问 8080 tcp 端口?

Working steps on port 8000 8000端口工作步骤

Server服务器

$ nc -lv 8000

Client客户

$ nc -z 192.168.101.98 8000
Connection to 192.168.101.98 port 8000 [tcp/irdmi] succeeded!

Non-working steps on port 8080端口 8080 上的非工作步骤

Server服务器

$ nc -lv 8080

Client客户

$ nc -z 192.168.101.98 8080 (The command just hangs) $ nc -z 192.168.101.98 8080 (命令就挂了)

Diagnostics诊断

$ lsof -P -i TCP:8000
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nc      75782 ...    3u  IPv4 0x5be3e11e5a732339      0t0  TCP *:8000 (LISTEN)

$ lsof -P -i TCP:8080
COMMAND   PID   USER   FD   TYPE             DEVICE SIZE/OFF NODE NAME
nc      75952 ...    3u  IPv4 0x5be3e11e581e2fb9      0t0  TCP *:8080 (LISTEN)

$ sudo pfctl -s all | grep Status
No ALTQ support in kernel
ALTQ related functions disabled
Status: Disabled                              Debug: Urgent

I am running macOS Mojave 10.14.1 (same behavior on 10.14 as well).我正在运行 macOS Mojave 10.14.1(在 10.14 上也有相同的行为)。

Update更新

I changed nothing, everything suddenly works.我什么都没改变,一切都突然起作用了。 I am very curious what made the difference.我很好奇是什么造成了不同。 Will close the question, if everything keeps working.如果一切正常,将结束这个问题。

Solution解决方案

I had the Endpoint Security VPN client installed.我安装了Endpoint Security VPN客户端。 This activates a firewall at all times blocking some ports.这会始终激活防火墙阻止某些端口。 Even when not connecting to a vpn server.即使没有连接到 vpn 服务器。

By shutting down the client daemon, i can access all ports again.通过关闭客户端守护程序,我可以再次访问所有端口。

Steps to shutdown daemon关闭守护进程的步骤

From: https://gist.github.com/phoob/671e65332c86682d5674来自: https : //gist.github.com/phoob/671e65332c86682d5674

kill client and run commands to stop daemon:杀死客户端并运行命令来停止守护进程:

sudo launchctl unload /Library/LaunchDaemons/com.checkpoint.epc.service.plist
sudo kextunload /Library/Extensions/cpfw.kext

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM