1. 设定代理:. ~/.proxyenv
1 #!/bin/sh 2 3 # for terminal 4 export proxyserveraddr=123.123.123.123 5 export proxyserverport=8087 6 export HTTP_PROXY="http://$proxyserveraddr:$proxyserverport/" 7 export HTTPS_PROXY="https://$proxyserveraddr:$proxyserverport/" 8 export FTP_PROXY="ftp://$proxyserveraddr:$proxyserverport/" 9 export SOCKS_PROXY="socks://$proxyserveraddr:$proxyserverport/" 10 export NO_PROXY="localhost,127.0.0.1,localaddress,.localdomain.com,200.200..;11.11.0.0;" 11 export http_proxy="http://$proxyserveraddr:$proxyserverport/" 12 export https_proxy="https://$proxyserveraddr:$proxyserverport/" 13 export ftp_proxy="ftp://$proxyserveraddr:$proxyserverport/" 14 export socks_proxy="socks://$proxyserveraddr:$proxyserverport/" 15 export no_proxy="localhost,127.0.0.1,localaddress,.localdomain.com,200.200..;11.11.0.0;" 16 17 # for chrome,firefox 18 gsettings set org.gnome.system.proxy ignore-hosts "[‘localhost‘, ‘11.11.0.0/16‘, ‘200.200.0.0/16‘, ‘*.localdomain.com‘ ]" 19 20 # for apt-get 21 cat <<-EOF| sudo tee /etc/apt/apt.conf 22 Acquire::http::proxy "http://$proxyserveraddr:$proxyserverport/"; 23 Acquire::https::proxy "https://$proxyserveraddr:$proxyserverport/"; 24 Acquire::ftp::proxy "ftp://$proxyserveraddr:$proxyserverport/"; 25 Acquire::socks::proxy "socks://$proxyserveraddr:$proxyserverport/"; 26 EOF
2. 取消代理:. ~/.unproxyenv
1 #!/bin/sh 2 unset proxyserveraddr 3 unset proxyserverport 4 unset HTTP_PROXY 5 unset HTTPS_PROXY 6 unset FTP_PROXY 7 unset SOCKS_PROXY 8 unset NO_PROXY 9 unset http_proxy 10 unset https_proxy 11 unset ftp_proxy 12 unset socks_proxy 13 unset no_proxy 14 gsettings reset org.gnome.system.proxy ignore-hosts 15 echo -n ""|sudo tee /etc/apt/apt.conf
〖Linux〗Ubuntu设定Proxy及忽略Proxy
时间: 2024-11-07 14:22:43