编辑用户变量
vi ~/.bashrc
添加以下代码
# set proxy
function proxy_set() {
export MY_PROXY=socks5h://192.168.10.25:1080
export no_proxy="localhost, 127.0.0.0/8, ::1/128, .local, 192.168.0.0/16, 10.0.0.0/8, 172.16.0.0/12"
export http_proxy=${MY_PROXY}
export HTTP_PROXY=${http_proxy}
export https_proxy=${MY_PROXY}
export HTTPS_PROXY=${https_proxy}
export all_proxy=${ALL_PROXY}
export ALL_PROXY=${MY_PROXY}
export FTP_PROXY=${MY_PROXY}
echo "proxy set! =${http_proxy}"
}
# unset proxy
function proxy_unset() {
unset no_proxy
unset http_proxy HTTP_PROXY https_proxy HTTPS_PROXY
unset all_proxy ALL_PROXY FTP_PROXY
echo "proxy unset@ <=${http_proxy}"
}
# enabled
proxy_set
然后就能使用代理了。
注意不能写在其他脚本里调用,因为父进程不一样。
标签:http,sock,socks5h,export,proxy,https,unset,PROXY From: https://www.cnblogs.com/yucloud/p/ubuntu_set_proxy.html