首页 > 代码库 > 〖Linux〗Ubuntu设定Proxy及忽略Proxy

〖Linux〗Ubuntu设定Proxy及忽略Proxy

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,firefox18 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-get21 cat <<-EOF| sudo tee /etc/apt/apt.conf22 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_proxy10 unset https_proxy11 unset ftp_proxy12 unset socks_proxy13 unset no_proxy14 gsettings reset org.gnome.system.proxy ignore-hosts15 echo -n ""|sudo tee /etc/apt/apt.conf