proxychains和graftcp和cgproxy使用方法
前言
proxychains新的版本已经称为proxychains-ng由rofl0r托管在GitHub中维护,一般使用proxychains用于加速更新和下载国外的一些开源组件,比如yum和pip。proxychains使用十分简单,甚至都不必编译安装。
新的代理方案可以由proxychains-ng过渡到graftcp或者cgproxy
更新历史
2022年11月07日 - 增加graftcp和cgproxy
2017年04月16日 - 初稿
阅读原文 - https://wsgzao.github.io/post/proxychains/
扩展阅读
proxychains-ng - https://github.com/rofl0r/proxychains-ng
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.
proxychains 安装配置
1 | # needs a working C compiler, preferably gcc |
proxychains.conf 配置文件
1 | [root@centos7 ~]# cat /etc/proxychains.conf |
环境变量代理设置
翻墙代理是用于访问 github 等不能直接访问的连接使用。
1 | # 使用时 export http_proxy; export https_proxy |
Similar projects
There are some awesome existing work:
- graftcp: work on most programs, but cannot proxy UDP (such as DNS) requests.
graftcp
also has performance hit on the underlying program, since it usesptrace
. - proxychains: easy to use, but not working on static linked programs (such as Go programs).
- proxychains-ng: similar to proxychains.
- cgproxy:
cgproxy
also uses cgroup to do transparent proxy, and the idea is similar tocproxy
‘s. There are some differences in UX and system requirements:cgproxy
requires systemcgroup
v2 support, whilecproxy
works with both v1 and v2.cgproxy
requires a background daemon processcgproxyd
running, whilecproxy
does not.cgproxy
requirestproxy
, which is optional incproxy
.cgproxy
can be used to do global proxy, whilecproxy
does not intended to support global proxy.
一个支持节点与订阅链接的 Linux 命令行代理工具 | A command-line tool for one-click proxy in your research and development without installing v2ray or anything else (only for linux)
gg 是一个命令行工具,可在 Linux 环境下对任意命令进行一键代理,而无需安装 v2ray 等其他工具。
你只需要在想代理的命令之前添加 gg
即可,例如: gg python -m pip install torch
.
感谢 graftcp 带来的灵感,gg 是它的一个纯 Go 语言实现,并且拥有更多的有用特性。
我为什么编写 go-graft?
我已经厌倦了我在科研和开发中所遇到的糟糕的网络状况。但我并不希望在我的几台工作服务器上安装 v2ray,因为它太笨重了,且配置麻烦。
因此,我需要一个轻巧便携的命令行工具来帮助我在各种服务器上下载和安装依赖项和软件。
优势
相比较于 proxychains 或 graftcp,go-graft 拥有以下优势:
- gg 下载即用,不需要安装任何额外的工具。
- 支持 UDP,从而有效应对 DNS 污染。
- 支持 Go 语言编写的程序。见 applications built by Go can not be hook by proxychains-ng 。