Mac終端配置代理

問題描述:

mac安裝telnet出現問題。

brew install telnet

 Failed to connect to 127.0.0.1 port 10010: Connection refused


MacBook-Pro:homebrew-core user$ brew install telnet
==> Downloading https://homebrew.bintray.com/bottles/telnet-60.mojave.bottle.tar.gz

curl: (7) Failed to connect to 127.0.0.1 port 10010: Connection refused
Error: Failed to download resource "telnet"
Download failed: https://homebrew.bintray.com/bottles/telnet-60.mojave.bottle.tar.gz
Warning: Bottle installation failed: building from source.
telnet: A full installation of Xcode.app is required to compile
this software. Installing just the Command Line Tools is not sufficient.

Xcode can be installed from the App Store.
Error: An unsatisfied requirement failed this build.
MacBook-Pro:homebrew-core lijianglong$ source ~/.bash_profile unproxy
MacBook-Pro:homebrew-core lijianglong$ brew install telnet
==> Download

查看代理:

env|grep -i proxy

爲:

ALL_PROXY=socks5://127.0.0.1:10010

故:使用代理導致訪問失敗

解決:

export http_proxy=""

export https_proxy=""

export HTTP_PROXY=""

export ALL_PROXY=""

可以直接在~/.bash_profile~/.zshrc~/.profile, or ~/.bashrc中添加一個函數進去。

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
# 開啓代理
proxy () {
	export https_proxy=http://127.0.0.1:10086
	export http_proxy=http://127.0.0.1:10001
	export ALL_PROXY=socks5://127.0.0.1:10010
	echo "Proxy on"
}

# 關閉代理
unproxy () {
	export https_proxy=""
	export http_proxy=""
	export ALL_PROXY=""
	echo "Proxy off"
}

之後執行source ~/.bash_profile(對應自己的startup files文件)。

需要開啓代理的時候就執行proxy,關閉就執行unproxy

 

再次執行安裝telnet成功!

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章