1.首先獲取自己的代理IP 和 端口呢撞∷鸾可以在網(wǎng)絡(luò)設(shè)置饰剥,高級設(shè)置中查看。
2.指定代理ip 端口摧阅,下面這種方式只在當前終端有效
//指定網(wǎng)頁代理(Http)
$export http_proxy=http://代理ip:端口
//指定網(wǎng)頁安全代理(Https)
$export https_proxy=http://代理ip:端口
//統(tǒng)一代理
$export ALL_proxy=http://代理ip:端口
//查看當前代理信息
$echo $http_proxy
$echo $https_proxy
如果是socks代理汰蓉,把http前綴改為socks5,例如:
$export http_proxy=socks5://代理ip:端口
3.配置所有終端窗口有效棒卷,配置bash_profile 文件
//編輯
$vim ~/.bash_profile
//生效
$source ~/.bash_profile
//查看
$cat ~/.bash_profile
4.增加開關(guān)模式更方便些顾孽,在~/.bash_profile 或者~/.zshrc (這個我沒測試)文件配置方法,如果輸入方法不識別比规,再輸入下
$source ~/.bash_profile
重新加載下配置文件若厚。
#終端設(shè)置代理
function proxy_on() {
#開啟代理
export http_proxy=socks5://代理ip:端口
export https_proxy=socks5://代理ip:端口
export all_proxy=socks5://代理ip:端口
echo '**********************開啟當前終端代理**********************'
}
function proxy_off() {
#移除代理
unset http_proxy
unset https_proxy
unset all_proxy
echo '**********************關(guān)閉當前終端代理**********************'
}
如何查看代理是否配置正確
curl cip.cc