linux终端代理设置
将下述内容写入~/.bashrc
,就可以通过proxy_on
和proxy_off
等指令对终端代理进行开关设置了。
注意: 端口号需要根据自己的代理客户端查看
function proxy_on() {export http_proxy=http://127.0.0.1:7897export https_proxy=$http_proxyecho -e "Terminal proxy on."
}function proxy_off(){unset http_proxy https_proxyecho -e "Terminal proxy off."
}
function check_proxy(){curl -I www.google.com --connect-timeout 10
}
执行check_proxy
,成功访问时大概显示内容如下:
a@a:~/桌面$ check_proxy
HTTP/1.1 200 OK
Transfer-Encoding: chunked
Cache-Control: private
Connection: keep-alive
Content-Security-Policy-Report-Only: object-src 'none';base-uri 'self';script-src 'nonce-sw-mjhV8fJD4FKiOnSbidg' 'strict-dynamic' 'report-sample' 'unsafe-eval' 'unsafe-inline' https: http:;report-uri https://csp.withgoogle.com/csp/gws/other-hp
Content-Type: text/html; charset=ISO-8859-1
Date: Tue, 05 Nov 2024 18:33:25 GMT
Expires: Tue, 05 Nov 2024 18:33:25 GMT
Keep-Alive: timeout=4
参考链接:
- https://blog.csdn.net/qq_40750972/article/details/123931306