Skip to content

Instantly share code, notes, and snippets.

@KnowSky404
Created September 2, 2025 02:33
Show Gist options
  • Select an option

  • Save KnowSky404/998d5376f9df18958c673fecded2df26 to your computer and use it in GitHub Desktop.

Select an option

Save KnowSky404/998d5376f9df18958c673fecded2df26 to your computer and use it in GitHub Desktop.
LinuxSetProxy
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