为apt-get和yum设置代理,以及Linux全局代理
apt-get
修改/etc/apt/apt.conf
添加内容
http代理
Acquire::http::proxy "http://127.0.0.1:8080/";
Acquire::ftp::proxy "http://127.0.0.1:8080/";
Acquire::https::proxy "http://127.0.0.1:8080/";
socks5代理
Acquire::http::proxy "socks5h://127.0.0.1:8080/";
Acquire::ftp::proxy "socks5h://127.0.0.1:8080/";
Acquire::https::proxy "socks5h://127.0.0.1:8080/";
如果代理有用户名和密码验证,就填写为以下格式
http://username:password@127.0.0.1:8080
yum
修改/etc/yum.conf
添加内容
proxy=http://127.0.0.1:8080
如果代理有用户名和密码验证,就填写为以下格式
proxy=http://127.0.0.1:8080
proxy_username=username
proxy_password=password
全局代理
CentOS修改/etc/skel/.bash_profile
Debian修改/etc/skel/.bashrc
添加内容
http_proxy=http://127.0.0.1:8080
https_proxy=http://127.0.0.1:8080
export http_proxy https_proxy
no_proxy=192.168.26.193,localhost,127.0.0.1
可以直接使用all_proxy,替代http_proxy和https_proxy
no_proxy为不走代理的地址
执行source /etc/skel/.bash_profile
或source /etc/skel/.bashrc
使更改生效