All things are difficult before they are easy. 没有软件的裸机是一具僵尸,没有硬件的软件是一个幽灵。2012,专注于Linux和C语言,关注自动化、性能测试,关注开源社区和开源测试工具、方法,尝试测试团队管理!

tsocks简介、安装、配置及遇到的问题

上一篇 / 下一篇  2011-09-24 11:33:55 / 个人分类:软件应用

原文来自我的博客:http://renyongjie668.blog.163.com/blog/static/16005312011824112410588/

最近配置了tsocks,解决了我的代理设置问题,也遇到了些配置相关的问题,本文主要简单介绍一下tsock的安装、配置、使用的方法。

 

关于tsocks:

http://tsocks.sourceforge.net/

SOCKS servers are a form. of proxy that are commonly used in firewalled LAN environments to allow access between networks, and often to the Internet. The problem is that most applications don't know how to gain access through SOCKS servers. This means that network based applications that don't understand SOCKS are very limited in networks they can reach. An example of this is simple 'telnet'. If you're on a network firewalled from the internet with a SOCKS server for outside access, telnet can't use this server and thus can't telnet out to the Internet.
tsocks' role is to allow these non SOCKS aware applications (e.g telnet, ssh, ftp etc) to use SOCKS without any modification. It does this by intercepting the calls that applications make to establish network connections and negotating them through a SOCKS server as necessary.

toscks可以应用程序不经过任何修改就可以轻松地使用已有socks代理,本人主要遇到的问题是ssh, telnet, git使用代理不是那么方便设置,用socks可以解决我的问题。

另外,tsocks是一个开源免费的项目,使用GPL License

 

下载和安装tsocks:

1.      rpm包安装:可以到http://pkgs.org/搜索tsocks,找到自己对应发行版的rpm

2.      Ubuntu等可以apt-get install tsocks来下载并安装

3.      源码安装:可以到这里下载http://tsocks.sourceforge.net/download.php并自己编译安装

BTW,我用的RHEL6u1系统,采用的是RPM安装方式)

 

配置tosck.conf

一般来说,tsocks的配置文件在/etc/tsocks.confrpm包安装好之后一般都会有这个文件,如果没有,也可以自己创建一个。可能Ubuntu等一些发行版,配置文件有所不同。

将我的配置文件/etc/tsocks.conf分享一下吧:

# This is the configuration for libtsocks (transparent socks)

# Lines beginning with # and blank lines are ignored

#

# This sample configuration shows the simplest (and most common) use of

# tsocks. This is a basic LAN, this machine can access anything on the

# local ethernet (192.168.0.*) but anything else has to use the SOCKS version

# 4 server on the firewall. Further details can be found in the man pages,

# tsocks(8) and tsocks.conf(5) and a more complex example is presented in

# tsocks.conf.complex.example

 

# We can access 10.*.*.* directly

local = 10.0.0.0/255.0.0.0

 

# Otherwise we use the server

server = proxy.xxx.com #your proxy domain or IP address

server_type = 5   #to use socks V5

server_port = 1080 #the port of your porxy

 

使用tsocks:

tsocks [application [applications arguments]]

tsocks [on|off]

举几个实例吧:

tsocks firefox  #之后再firefox上浏览网页就会默认使用tsocks配置的代理

tsocks git clone git://github.com/avikivity/kvm.git #使用proxygit,这就是我用的原因

 

source tsocks on #设置当前shelltsocks,该命令可能遇到一个小bug在下面有讲到

tsocks show    #查看当前Shelltsocks设置,tsocks: This shell is socksified.

do_something   #这里就能默认使用tsocks的代理去do something了,前面已经设置了

source tsocks off #关闭当前shelltsocks代理设置

tsocks show    #再次查看,tsocks: This shell is NOT socksified.

 

 

遇到的问题及解决方案:

13:01:17 libtsocks(2432): SOCKS server proxy-shz.intel.com (10.239.120.36) is not on a local subnet!
设置的代理没有与/etc/tsocks.conf文件中的local设置的网络在同一个子网中。

3:03:26 libtsocks(2451): The SOCKS server (proxy.ABCD.com) listed in the configuration file which needs to be used for this connection is invalid
配置文件的问题,我也忘了是啥时出现的错误了,但我碰到过的。
13:02:50 libtsocks(2441): Error 110 attempting to connect to SOCKS server (Connection timed out)
这个很明显了,就是你设置的proxy连接不上(可能是本来就连不上,或者没在同一个局域网内),请检查和确认配置。

ERROR: ld.so: object '/lib64/libtsocks.so' from LD_PRELOAD cannot be preloaded: ignored.
郁闷坏了,是因为有一次我在rhel5u5上安装了一个rhel6tsock rpm包,解决办法是到http://pkgs.org/找到一个tsocks for rhel5rpm包,安装即可。

 

[root@kvm-build ~]# source /usr/bin/tsocks on

basename: invalid option -- 'b'

Try `basename --help' for more information.

看到这样的错误,有可能是你的tsocks有点小bug,不过不影响使用的,接着你用tsocks show来看,一样可以看到提示说socks设置成功的,tsocks: This shell is socksified.


TAG: Linux proxy tsocks 代理 代骂

 

评分:0

我来说两句

smile665

smile665

Stay hungry, stay foolish. 得意之时谨记,一半命运还掌握在上帝手里;失意之时须知,一半命运还掌握在自己手里。

日历

« 2024-03-27  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 952634
  • 日志数: 220
  • 建立时间: 2008-11-06
  • 更新时间: 2012-10-06

RSS订阅

Open Toolbar