Created
September 2, 2025 02:33
-
-
Save KnowSky404/998d5376f9df18958c673fecded2df26 to your computer and use it in GitHub Desktop.
LinuxSetProxy
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| setproxy() { | |
| local proxy="http://127.0.0.1:20171" | |
| for v in http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY; do | |
| export $v="$proxy" | |
| done | |
| echo "Proxy set to $proxy" | |
| # auto check proxy | |
| if curl -s --connect-timeout 5 -I https://www.google.com --proxy $proxy | grep "200" >/dev/null; then | |
| echo "✅ Proxy is working (Google reachable)" | |
| else | |
| echo "⚠️ Proxy set, but Google is NOT reachable" | |
| fi | |
| } | |
| unsetproxy() { | |
| for v in http_proxy https_proxy all_proxy HTTP_PROXY HTTPS_PROXY ALL_PROXY; do | |
| unset $v | |
| done | |
| echo "Proxy cleared" | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment