## 临时设置 设置代理 export http_proxy="http://127.0.0.1:20171" export https_proxy="http://127.0.0.1:20171" 取消设置代理 unset http_proxy https_proxy **此方式不支持socket5代理** ## proxychains 前情提要:因为要按照某个软件,但是有网络监测机制,一直报错,所以就需要通过代理来运行。 安装: `sudo apt update` `sudo apt install proxychains -y` 配置: `sudo vim /etc/proxychains.conf` 在末尾添加 `socks5 127.0.0.1 20170` 然后就可以使用了。 重要知识点:ping 不能被代理! ping 使用的是 ICMP 协议,不是 TCP/HTTP/SOCKS。 proxychains 只能代理 TCP 和 UDP 连接(比如 curl, wget, git, ssh 等)。 所以你用 proxychains ping ... 是无效的,而且会报错或被忽略。 正确测试 proxychains 是否工作的命令是使用 curl 或 wget ```bash (base) dellevin@dellevin-G3-3579:~/Desktop/WhiteSur-gtk-theme$ proxychains curl -v google.com ProxyChains-3.1 (http://proxychains.sf.net) |DNS-request| google.com |S-chain|-<>-127.0.0.1:20170-<><>-4.2.2.2:53-<><>-OK |DNS-response| google.com is 142.250.189.238 * Host google.com:80 was resolved. * IPv6: (none) * IPv4: 142.250.189.238 * Trying 142.250.189.238:80... |S-chain|-<>-127.0.0.1:20170-<><>-142.250.189.238:80-<><>-OK * Connected to google.com (142.250.189.238) port 80 * using HTTP/1.x > GET / HTTP/1.1 > Host: google.com > User-Agent: curl/8.12.1 > Accept: */* > * Request completely sent off < HTTP/1.1 301 Moved Permanently < Location: http://www.google.com/ < Content-Type: text/html; charset=UTF-8 < Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-p85NwNurE8Yc0yBkcHZmUQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp < Date: Sat, 23 Aug 2025 05:50:49 GMT < Expires: Mon, 22 Sep 2025 05:50:49 GMT < Cache-Control: public, max-age=2592000 < Server: gws < Content-Length: 219 < X-XSS-Protection: 0 < X-Frame-Options: SAMEORIGIN < 301 Moved 301 Moved The document has moved here. * Connection #0 to host google.com left intact ``` 这样说明我已经可以正常访问了 Loading... ## 临时设置 设置代理 export http_proxy="http://127.0.0.1:20171" export https_proxy="http://127.0.0.1:20171" 取消设置代理 unset http_proxy https_proxy **此方式不支持socket5代理** ## proxychains 前情提要:因为要按照某个软件,但是有网络监测机制,一直报错,所以就需要通过代理来运行。 安装: `sudo apt update` `sudo apt install proxychains -y` 配置: `sudo vim /etc/proxychains.conf` 在末尾添加 `socks5 127.0.0.1 20170` 然后就可以使用了。 重要知识点:ping 不能被代理! ping 使用的是 ICMP 协议,不是 TCP/HTTP/SOCKS。 proxychains 只能代理 TCP 和 UDP 连接(比如 curl, wget, git, ssh 等)。 所以你用 proxychains ping ... 是无效的,而且会报错或被忽略。 正确测试 proxychains 是否工作的命令是使用 curl 或 wget ```bash (base) dellevin@dellevin-G3-3579:~/Desktop/WhiteSur-gtk-theme$ proxychains curl -v google.com ProxyChains-3.1 (http://proxychains.sf.net) |DNS-request| google.com |S-chain|-<>-127.0.0.1:20170-<><>-4.2.2.2:53-<><>-OK |DNS-response| google.com is 142.250.189.238 * Host google.com:80 was resolved. * IPv6: (none) * IPv4: 142.250.189.238 * Trying 142.250.189.238:80... |S-chain|-<>-127.0.0.1:20170-<><>-142.250.189.238:80-<><>-OK * Connected to google.com (142.250.189.238) port 80 * using HTTP/1.x > GET / HTTP/1.1 > Host: google.com > User-Agent: curl/8.12.1 > Accept: */* > * Request completely sent off < HTTP/1.1 301 Moved Permanently < Location: http://www.google.com/ < Content-Type: text/html; charset=UTF-8 < Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-p85NwNurE8Yc0yBkcHZmUQ' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp < Date: Sat, 23 Aug 2025 05:50:49 GMT < Expires: Mon, 22 Sep 2025 05:50:49 GMT < Cache-Control: public, max-age=2592000 < Server: gws < Content-Length: 219 < X-XSS-Protection: 0 < X-Frame-Options: SAMEORIGIN < <HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8"> <TITLE>301 Moved</TITLE></HEAD><BODY> <H1>301 Moved</H1> The document has moved <A HREF="http://www.google.com/">here</A>. </BODY></HTML> * Connection #0 to host google.com left intact ``` 这样说明我已经可以正常访问了 最后修改:2025 年 08 月 24 日 © 允许规范转载 打赏 赞赏作者 支付宝微信 赞 如果觉得我的文章对你有用,请随意赞赏