使用proxychain4進(jìn)行終端代理

使用proxychain4進(jìn)行終端代理

引言(introduction)

在日常工作生活中,經(jīng)常遇到使用 wget或者 git時(shí),下載文件且文件在國內(nèi)下載慢甚至不能下載的情況,需要在終端使用代理。發(fā)現(xiàn)proxychains很方便好用。

proxychains

我們可以從github倉庫看到關(guān)于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

網(wǎng)上有些博文寫的 proxychains4/etc/proxychains4.conf。
當(dāng)然是可以的,但就直接 /etc/proxychains.conf 也會(huì)生效。
甚至兩個(gè)文件都存在的時(shí)候 proxychains.conf 的優(yōu)先級(jí)比 proxychains4.conf 高。

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

[ProxyList]
# add proxy here ...
# meanwile
# defaults set to "tor"
#socks4         127.0.0.1 9050
socks5         [子網(wǎng)IP] [socket端口]

測試

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

接口返回的兩個(gè)本機(jī)IP不一致,說明開啟代理成功了。

使用

例如使用git克隆一個(gè)較大的倉庫,在原本輸入的命令前加入proxychain4即可

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

參考文檔

使用proxychain4安裝zsh

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容