给出了一个windows机器A和一个linux机器B,我尝试实现这解决方案(也可以在这网站上阅读),通过A(机器A有互联网接入)访问B上的internet。
在windows机器A上,我打开了一个powershell,并写道
netsh winhttp set proxy 127.0.0.1:8000在linux机器B上,我在/etc/环境文件中设置了
export http_proxy=http://127.0.0.1:7000
export https_proxy=http://127.0.0.1:7000然后我用
source /etc/environment然后,按照引用的链接,我进行了远程端口转发(据我理解,这意味着在linux机器B的端口7000上发生的一切都将被转发到windows机器A的端口8000 ),因此我在windows机器A上的一个终端中编写了以下内容:
ssh -R 7000:localhost:8000 user@hostB现在我以为我结束了。但是,当我从linux机器B尝试这个命令时
wget http://google.com我得到了
--2022-04-03 10:08:28-- http://google.com/
Resolving localhost (localhost)... 127.0.0.1, ::1
Connecting to localhost (localhost)|127.0.0.1|:7000... connected.
Proxy request sent, awaiting response... No data received.
Retrying.
--2022-04-03 10:08:31-- (try: 2) http://google.com/
Connecting to localhost (localhost)|127.0.0.1|:7000... connected.
Proxy request sent, awaiting response... No data received.
Retrying.
--2022-04-03 10:08:35-- (try: 3) http://google.com/
Connecting to localhost (localhost)|127.0.0.1|:7000... connected.
Proxy request sent, awaiting response... No data received.
Retrying.
...我完全是初学者,所以如果有人能解释我如何让它工作,我很感激。
发布于 2022-04-08 11:00:50
如果Linux系统上的应用程序可以使用SOCKS,则可以使用ssh的SOCKS代理来简化网络连接。
Windows:
ssh -D 1080 linuxServer # add -fN to run in the background现在有一个SOCKS服务器监听linuxServer上的端口1080,通过ssh会话通过您的Windows路由。
Linux:
您需要安装SOCKS代理(如tsocks ),或者使用SOCKS感知应用程序(如wget )。以root的形式运行这些代码(使用sudo -s获取根shell):
apt install tsocks # Install the tool
cp -p /etc/tsocks.conf /etc/tsocks.conf.ORIGINAL # I like to save configuration files before changing them
echo server = 127.0.0.1 >/etc/tsocks.conf # Minimal configuration现在,您可以在网络命令或应用程序前面加上tsocks,以使用您在第一步中创建的SOCKS代理:
tsocks wget https://bbc.co.uk/不是所有的命令都与tsocks一起工作。特别是ping无法工作,您将收到错误,ERROR: ld.so: object 'libtsocks.so' from LD_PRELOAD cannot be preloaded (cannot open shared object file): ignored.。
https://unix.stackexchange.com/questions/697926
复制相似问题