我有一个不使用的 VPS,但它没有太多内存。我在 PC 上设置了一个 minecraft 服务器,但我不想进行端口转发。有没有办法使用 SSH 隧道让我的服务器正常工作?
答案1
如果您确实想通过 ssh 尝试使用 -L 选项
-L [bind_address:]port:host:hostport
Specifies that the given port on the local (client) host is to be forwarded to the given host and port on the remote side. This works by allocating a
socket to listen to port on the local side, optionally bound to the specified bind_address. Whenever a connection is made to this port, the connection
is forwarded over the secure channel, and a connection is made to host port hostport from the remote machine. Port forwardings can also be specified in
the configuration file. IPv6 addresses can be specified by enclosing the address in square brackets. Only the superuser can forward privileged ports.
By default, the local port is bound in accordance with the GatewayPorts setting. However, an explicit bind_address may be used to bind the connection
to a specific address. The bind_address of “localhost” indicates that the listening port be bound for local use only, while an empty address or ‘*’
indicates that the port should be available from all interfaces.
您需要通过 ssh 连接到服务器(使用此选项),然后保持该 ssh 连接运行,以便使用端口转发。然后您的服务器应该可以在 127.0.0.1:port 上使用
答案2
我使用 Logmein 的 hamachi 程序在大学里托管了一个服务器,取得了很大成功。您的客户需要安装该软件,但您可以创建一个自定义的可执行文件,客户无需手动输入任何设置即可进行设置。
如果 minecraft 支持的话,IPv6 隧道可能是另一个选择。