通过SSH隧道转发所有stream量

我希望有人能跟随这个,我会尽我所能解释。

我试图通过SSH隧道将XXX224上的端口6999的所有stream量转发到xxx218上的端口7000上。

这是一些ASCII艺术:

|browser|-----|Squid on xxx224|------|ssh tunnel|------<satellite link>-----|Squid on xxx218|-----|www| 3128 6999 7000 80 

当我删除SSH隧道,一切工作正常。

这个想法是closuresSSH隧道encryption(以节省带宽),并打开最大压缩(以节省更多的带宽)。 这是因为它是一个卫星链路。

这是我一直使用的SSH隧道:

 ssh -C -f -C -o CompressionLevel=9 -o Cipher=none [email protected] -L 7000:172.16.1.224:6999 -N 

麻烦的是,我不知道如何从xxx224上的squid获取数据到ssh隧道中? 我是否以错误的方式去做这件事? 我应该在xxx218上创build一个ssh隧道吗? 我使用iptables在xxx224上从读取端口80停止squid,而是从端口6999反馈(即通过ssh隧道)。 我需要另一个iptables规则吗?

任何意见不胜感激。

提前谢谢了,


关于爱德华多Ivanec的问题,这里是一个netstat -i any port 7000 -nn转储从xxx218:

 14:42:15.386462 IP 172.16.1.224.40006 > 172.16.1.218.7000: Flags [S], seq 2804513708, win 14600, options [mss 1460,sackOK,TS val 86702647 ecr 0,nop,wscale 4], length 0 14:42:15.386690 IP 172.16.1.218.7000 > 172.16.1.224.40006: Flags [R.], seq 0, ack 2804513709, win 0, length 0 

更新2:

当我运行第二个命令时,在浏览器中出现以下错误:

 ERROR The requested URL could not be retrieved The following error was encountered while trying to retrieve the URL: http://109.123.109.205/index.php Zero Sized Reply Squid did not receive any data for this request. Your cache administrator is webmaster. Generated Fri, 01 Jul 2011 16:06:06 GMT by remote-site (squid/2.7.STABLE9) 

远程站点是172.16.1.224

当我做一个tcpdump -i any port 7000 -nn

我得到以下内容:

 root@remote-site:~# tcpdump -i any port 7000 -nn tcpdump: verbose output suppressed, use -v or -vv for full protocol decode listening on any, link-type LINUX_SLL (Linux cooked), capture size 65535 bytes channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused channel 2: open failed: connect failed: Connection refused 

如果我正确地理解了你的话,你的隧道定义就有问题了。 你目前的命令行似乎是将当前主机上的7000端口(我假设为.224)的stream量转发到.224端口6999。

试试这个:

 ssh -N -g -f -C -o CompressionLevel=9 -o Cipher=none [email protected] -L 6999:172.16.1.218:7000 

或者,如果172.16.1.218:7000不是直接可达的(我猜测它不是),否则直接连接到它可能意味着连接到172.16.1.218:

 ssh -N -g -f -C -o CompressionLevel=9 -o Cipher=none [email protected] -L 6999:localhost:7000 

-L的格式是<localport>:<remotehost>:<remoteport><remotehost>是相对于目标主机,所以在这种情况下localhost应该工作。

注意我添加了-g ,以防你想使用不同于.224的机器的隧道(我假设你是在224上运行ssh)。