原贴:http://cb.vu/unixtoolbox.xhtml
On client cliuser (from destination to gate):
Connect two clients behind NAT
Suppose two clients are behind a NAT gateway and client cliadmin has to connect to client cliuser (the destination), both can login to the gate with ssh and are running Linux with sshd. You don't need root access anywhere as long as the ports on gate are above 1024. We use 2022 on gate. Also since the gate is used locally, the option GatewayPorts is not necessary.On client cliuser (from destination to gate):
# ssh -R 2022:localhost:22 user@gate # forwards client 22 to gate:2022On client cliadmin (from host to gate): # ssh -L 3022:localhost:2022 admin@gate # forwards client 3022 to gate:2022Now the admin can connect directly to the client cliuser with: # ssh -p 3022 admin@localhost # local:3022 -> gate:2022 -> client:22
本文介绍了一种通过SSH建立隧道让位于NAT后的两台客户端互相连接的方法。具体步骤包括:从目的端cliuser到网关转发本地22端口到网关的2022端口;从发起端cliadmin到网关转发本地3022端口到网关的2022端口。之后发起端可通过本地3022端口直接连接到目的端。
1227

被折叠的 条评论
为什么被折叠?



