考虑以下情况:
在我家里,我有一个路由器(连接到互联网)、服务器(S)和我的主机(M)。S 可从 Internet 访问(它具有静态 IP),并且 24/7 全天候运行,而 M 则不然。
有时,我想让一些应用程序(它侦听 M 上的某个端口,例如 8888)可以从外部 Internet 访问。
为此,我想在 S (2222) 上设置一些端口以转发到 M 的端口 8888,以便任何访问 S:2222 的人都感觉他正在访问 M:8888。
我尝试使用 ssh 端口转发,我最好的尝试如下:
ssh -L 2222:M:8888 -N M
Run Code Online (Sandbox Code Playgroud)
但这仅允许我从服务器本身访问 2222 端口,而不能从其他机器访问。
Is there some way to do it properly? Preferably, I'd like it to be a simple command, which I would be able to start and shut down with ^C when I don't need that forwarding anymore.