我想允许我的家庭网络中的一些客户端设备连接到Internet,但是连接应该通过我的iMac进行,该iMac具有到远程服务器的SSH隧道。我最终希望使用远程服务器的Internet连接代表客户端设备发出请求。
在iMac上,我使用
ssh -D 8127 -f -g -N -C -vvv myuser@remote_server
我在iMac上使用代理localhost:8127配置了浏览器,并且一切正常。我连接到的Web服务器看到来自remote_server的传入连接。到目前为止,一切都很好。
但是,当我在客户端中配置相同的代理设置时,我什么也没回来。我的Windows笔记本电脑上的浏览器返回“连接已重置”。我尝试使用Android设备和iPad。他们都不工作。
隧道中的详细日志显示得并不多。
debug1: Connection to port 8127 forwarding to socks port 0 requested.
debug2: fd 12 setting TCP_NODELAY
debug3: fd 12 is O_NONBLOCK
debug3: fd 12 is O_NONBLOCK
debug1: channel 5: new [dynamic-tcpip]
debug2: channel 5: pre_dynamic: have 0
debug2: channel 5: pre_dynamic: have 411
debug2: channel 5: zombie
debug2: channel 5: garbage collecting
debug1: channel 5: free: dynamic-tcpip, nchannels 7
debug3: channel 5: status: The following connections are open:
#2 direct-tcpip: listening port 8127 for 188.65.124.58 port 443, connect from 127.0.0.1 port 61067 to 127.0.0.1 port 8127 (t4 r0 i0/0 o0/0 fd 9/9 cc -1)
#3 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61091 to 127.0.0.1 port 8127 (t4 r1 i0/0 o0/0 fd 10/10 cc -1)
#4 direct-tcpip: listening port 8127 for 66.102.1.189 port 443, connect from 127.0.0.1 port 60990 to 127.0.0.1 port 8127 (t4 r2 i0/0 o0/0 fd 11/11 cc -1)
#6 direct-tcpip: listening port 8127 for 172.217.22.206 port 443, connect from 127.0.0.1 port 61092 to 127.0.0.1 port 8127 (t4 r4 i0/0 o0/0 fd 13/13 cc -1)
有谁知道为什么这不起作用?
您仅绑定到本地主机端口。在man ssh
此部分的文档(请参阅参考资料)中并不清楚:
默认情况下,本地端口是根据
GatewayPorts
设置绑定的。但是,可以使用显式bind_address将连接绑定到特定地址。的bind_addresslocalhost
指示绑定的侦听端口仅供本地使用,而地址为空或*
指示该端口应可从所有接口使用。
来自ssh_config
:
GatewayPorts指定是否允许远程主机连接到本地转发的端口。默认情况下,
ssh
(1)将本地端口转发绑定到环回地址。这样可以防止其他远程主机连接到转发的端口。GatewayPorts
可以用来指定ssh
应该将本地端口转发绑定到通配符地址,从而允许远程主机连接到转发的端口。参数必须为“是”或“否”。默认为“否”。
这意味着在使用时,您使用的ssh -D 8127
是根据绑定的端口GatewayPorts
,默认为localhost
,即远程主机无法连接。
如果指定,ssh -D :8127
则包括对地址的引用,并且由于该地址为空,因此默认为*
,即远程主机可以连接。
将您的命令更改为此,它将按您的意愿工作:
ssh -D :8127 -f -g -N -C -vvv myuser@remote_server
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句