使用proxychain4进行终端代理

使用proxychain4进行终端代理

引言(introduction)

在日常工作生活中,经常遇到使用 wget或者 git时,下载文件且文件在国内下载慢甚至不能下载的情况,需要在终端使用代理。发现proxychains很方便好用。

proxychains

我们可以从github仓库看到关于proxychains的介绍:

ProxyChains is a UNIX program, that hooks network-related libc functions in DYNAMICALLY LINKED programs via a preloaded DLL (dlsym(), LD_PRELOAD) and redirects the connections through SOCKS4a/5 or HTTP proxies.

It supports TCP only (no UDP/ICMP etc).

The way it works is basically a HACK; so it is possible that it doesn't work with your program, especially when it's a script, or starts numerous processes like background daemons or uses dlopen() to load "modules" (bug in glibc dynlinker).

It should work with simple compiled (C/C++) dynamically linked programs though.

If your program doesn't work with proxychains, consider using an iptables based solution instead; this is much more robust.

Supported Platforms: Linux, BSD, Mac, Haiku.

安装

sudo apt install proxychains4 

配置

vim /etc/proxychains4.conf

网上有些博文写的 proxychains4/etc/proxychains4.conf
当然是可以的,但就直接 /etc/proxychains.conf 也会生效。
甚至两个文件都存在的时候 proxychains.conf 的优先级比 proxychains4.conf 高。

中间都不用管,直接拉到最后:

[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
#socks4         127.0.0.1 9050
socks5         [子网IP] [socket端口]

测试

$ curl www.httpbin.org/ip
$ proxychains4 curl www.httpbin.org/ip

接口返回的两个本机IP不一致,说明开启代理成功了。

使用

例如使用git克隆一个较大的仓库,在原本输入的命令前加入proxychain4即可

❯ proxychains4 git clone https://github.com/haad/proxychains.git

参考文档

使用proxychain4安装zsh

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容