简体   繁体   English

侦听端口腻子隧道不起作用

[英]Listening port putty tunnel does not work

The goal is to connect to my home computer from outside. 目标是从外部连接到我的家用计算机。 The ISP blocks all the ports (and demands $$$ for business package with static ip address), so simple port forwarding on home router does not work. ISP阻止了所有端口(并且对具有静态IP地址的业务包要求$$的费用),因此家用路由器上的简单端口转发不起作用。

I have used putty to tunnel a listening port to a remote server: R2221:###.###.###.###:2221 (to make things simpler, the test server is a simple ftp server running on my home windows machine) (the entire ip address has to be specified -- with OpenSSH 1.0 running on the linux box wildcard address results in refusal of connection) (GatewayPorts are set to on). 我已经使用腻子将侦听端口通过隧道传输到远程服务器:R2221:###。###。###。###:2221(为了简化起见,测试服务器是在我的服务器上运行的简单ftp服务器家用Windows机器)(必须指定整个IP地址-在Linux盒上使用OpenSSH 1.0运行通配符地址会导致拒绝连接)(GatewayPorts设置为on)。

Netstat -a confirms that port 2221 on the linux box is open and listening. Netstat -a确认linux机器上的端口2221已打开并正在侦听。 However, whenever I try to connect to that port, it simply hangs. 但是,每当我尝试连接到该端口时,它都会挂起。 Command line ftp client says "connected to ###.###.###.###" and that's it. 命令行ftp客户端说“已连接到###。###。###。###”,仅此而已。 Running netstat again shows dozens of opened connections to port 2221, all coming from my windows box (I tried using browser as well as command line ftp client). 再次运行netstat将显示到端口2221的数十个打开的连接,所有连接都来自我的Windows框(我尝试使用浏览器以及命令行ftp客户端)。

Which step am I missing? 我错过了哪一步?

Tried with RDP, VNC and FTP -- all of them hang, all of them connect when connecting through my home network (or my home router). 通过RDP,VNC和FTP进行了尝试-它们全部挂起,并且在通过我的家庭网络(或我的家庭路由器)进行连接时它们都可以连接。

EDIT The setup is as follows: 编辑设置如下:

PC 1 (windows) has FTP service running on port 2221. It uses PuTTY to tunnel a listening port to PC 2 (linux). PC 1(Windows)在端口2221上运行FTP服务。它使用PuTTY将侦听端口传送到PC 2(Linux)。 PC 2 does show listening port when running netstat. 运行netstat时,PC 2确实显示了侦听端口。 Connecting to port 2221 on PC 2 either form PC 2 or from PC 3 results in hanging. 从PC 2或从PC 3连接到PC 2上的端口2221导致挂起。

EDIT 2 Aaaand it worked. 编辑2 Aaa和它的工作原理。 Using 127.0.0.1 instead of the remote machine's ip address was what corrected it. 更正了它,而不是使用127.0.0.1的远程计算机的IP地址。 Thanks a lot. 非常感谢。

Are you sure your -R command is correct? 您确定您的-R命令正确吗? From what you say I suppose the command should be R2221:127.0.0.1:2221 . 根据您所说的,我想命令应该是R2221:127.0.0.1:2221 The -R ssh option in form of port:host:hostport does the following: it opens port port on the remote side and forwards the connection to that port to local address host:hostport , and this connection is made from the local machine. port:host:hostport形式的-R ssh选项执行以下操作:它在远程侧打开端口port ,并将与该端口的连接转发到本地地址host:hostport ,并且此连接是从本地计算机建立的。

To make your local machine (the one that is running ssh client, eg PuTTY) connect to your local FTP server running on the same machine, use 127.0.0.1 as an address. 要使本地计算机(运行ssh客户端的计算机,例如PuTTY)连接到在同一计算机上运行的本地FTP服务器,请使用127.0.0.1作为地址。

It also explains why you see a strange behaviour: when you actually connect to xxx.xxx.xxx.xxx:2221, it forwards the connection to the same address xxx.xxx.xxx.xxx:2221 and you get some kind of a loop. 它还说明了为什么您会看到奇怪的行为:当您实际连接到xxx.xxx.xxx.xxx:2221时,它将连接转发到相同的地址xxx.xxx.xxx.xxx:2221并得到了某种循环。

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

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