這里分別介紹下下常用的yum、wget、lftp等常用程序的設置。
一、wget下的代理設置
1、臨時生效
set "http_proxy=http://[user]:[pass]@host:port/" 或 export "http_proxy=http://[user]:[pass]@host:port/"
執行完,就可以在當前shell 下使用wget程序了。
2、使用wget參數
wget -e "http_proxy=http://[user]:[pass]@host:port/" http://baidu.com
3、當前用戶永久生效
創建$HOME/.wgetrc文件,加入以下內容:
http_proxy=代理主機IP:端口
配置完后,就可以通過代理wget下載包了。
注:如果使用ftp代理,將http_proxy 改為ftp_proxy 即可。
二、lftp下代理設置
使lftp可以通過代理上網,可以做如下配置
echo "export http_proxy=proxy.361way.com:8888" > ~/.lftp
三、yum設置
編輯/etc/yum.conf文件,按如下配置
proxy=http://yourproxy:8080/ #匿名代理 proxy=http://username:password@yourproxy:8080/ #需驗證代理
四、全局代理配置
編輯/etc/profile 或~/.bash_profile ,增加如下內容:
http_proxy=proxy.361way.com:8080 https_proxy=proxy.361way.com:8080 ftp_proxy=proxy.361way.com:8080 export http_proxy https_proxy ftp_proxy
五、socket代理配置
這里以兩個常見的socket代理軟件socks5 和 tsocks 為例:
1、tsocks代理
在終端中: sudo apt-get install tsocks 修改配置文件: sudo nano /etc/tsocks.conf
將其內容改成以下幾行並保存退出:
local = 192.168.1.0/255.255.255.0 #local表示本地的網絡,也就是不使用socks代理的網絡 server = 127.0.0.1 # SOCKS 服務器的 IP server_type = 5 # SOCKS 服務版本 server_port = 9999 #SOCKS 服務使用的端口
運行軟件:
用 tsocks 運行你的軟件很簡單,在終端中:tsocks 你的軟件 ,如tsocks wget url
2、socks5代理
安裝socks客戶端工具runsocks(正常安裝socks5后自帶)。在libsocks5.conf文件里加入所要使用的代理服務器。配置完成,可以通過如下命令運行測試:
runsocks wget -m [http://site1 | ftp://site2]
轉至 運維之路