配置apt-get使用socks代理
本文可自由转载,但请遵循“署名-非商业用途-保持一致”的创作共用协议。 永久链接:JoeCen's 小猫窝-----------------------------
因为想在debian安装xgl,总要在sources.list里面设置一下国外的source,非常慢。所以希望设置socks代理来进行连接。
从sources.conf的man里面发现,apt只支持http proxy,但是我使用ssh代理产生的socks5更方便。那么只能使用
tsocks
来进行socks代理了。
安装:
apt-get install tsocks
使用前设置conf文件
vi /etc/tsocks.conf
做一个简单的配置就好了:
local = 192.168.1.0/255.255.255.0 #local表示本地的网络,也就是不使用socks代理的网络
local = 127.0.0.0/255.0.0.0
server = 127.0.0.1 #socks服务器的IP
server_type = 5 #socks服务版本
server_port = 7070 #socks服务使用的端口
local = 127.0.0.0/255.0.0.0
server = 127.0.0.1 #socks服务器的IP
server_type = 5 #socks服务版本
server_port = 7070 #socks服务使用的端口
要注意的是"server"中的IP必须包含在"local"里面,否则不能使用,比如使用apt更新的时候会报下面这个错误:
0% [Working]20:13:21 libtsocks(11619): SOCKS server xxx.xx.xxx.xxx (xxx.xxx.xxx.xxx) is not on a local subnet!
使用tsocks代理apt-get:
tsocks apt-get update
tsocks aptitude upgrade
...
tsocks aptitude upgrade
...
很简单,就是在命令前面加上"tsocks"就可以了,tsocks会使用"exec"来运行命令。
February 5th, 2009 at 1:44 pm Quote
thanks, tsocks, it's so Cool~. hoho
January 4th, 2010 at 2:26 pm Quote
Good job.
Thanks
May 2nd, 2010 at 7:28 pm Quote
我的socks代理好快,终于照这篇文章装好了sun-java-jre