Chinaunix首页 | 论坛 | 博客
  • 博客访问: 101089938
  • 博文数量: 19283
  • 博客积分: 9968
  • 博客等级: 上将
  • 技术积分: 196062
  • 用 户 组: 普通用户
  • 注册时间: 2007-02-07 14:28
文章分类

全部博文(19283)

文章存档

2011年(1)

2009年(125)

2008年(19094)

2007年(63)

分类: LINUX

2008-03-23 11:01:09

来源:赛迪网    作者:korn

系统平台为Fedora 8,Tor版本为tor-0.2.0.19-alpha。

第一步:下载并安装Tor

在官方网站下载最新版本的Tor,我下载的是tor-0.2.0.19-alpha.tar.gz,考虑到系统兼容性,我下载的是非RPM的包。

tar zxvf tor-0.2.0.19-alpha.tar.gz

cd tor-0.2.0.19-alpha

./configure

make

make install

如果顺利的话应该就安装成功了,不过我在configure时遇到一下的出错信息而中断:

checking whether we need extra options to link libevent… configure: error: Found linkable libevent in (system), but it does not seem to run, even with -R. Maybe specify another using –with-libevent-dir}

虽然Fedora 8日已经安装好libevent的包的,但显然配置程序并没有找到默认路径,这时候我只能到libevent的官方网站下载最新的libevent版本:

~provos/libevent/

~provos/libevent-1.4.1-beta.tar.gz

libevent包的安装方式类似,很顺利,然后回到Tor的目录里重新指定libevent目录重新安装:

./configure –with-libevent-dir=/usr/local/lib

make

make install

顺利安装成功。

第二步:设置Tor的配置文件

默认安装好以后,主要配置文件在/usr/local/etc/tor/目录下,有个torrc.sample文件。

cp torrc.sample torrc

mkdir /var/log/tor

touch /var/log/tor/notices.log

touch /var/log/tor/debug.log

mkdir /var/run/tor

touch /var/run/tor/tor.pid

mkdir /var/lib/tor

编辑torrc文件并把以下配置打开并设置:

SocksPort 9050

SocksListenAddress 127.0.0.1

Log notice file /var/log/tor/notices.log

Log debug file /var/log/tor/debug.log

#注意debug.log文件增加很快,如果是平时正常运行时不建议打开,但刚安装调试时可以测试效果。

DataDirectory /var/lib/tor

#此目录为tor主要的运行数据存放目录包括key文件等。

Nickname yourname

#这个名称设置可以自己定义,字母或数字即可,不可以有空格或符号。

ContactInfo

#这里定义你的email联系信息,据说是以便Tor联系你。

ORPort 9001

这个文件里主要就是以上这些配置,其它还有一些带宽配置等,如果觉得需要的话,可以以后再配置。

第三步:设置Tor启动和控制文件

以上配置好以后,默认情况下已经可以通过/usr/local/bin/tor -f /usr/local/etc/tor/torrc &来把服务运行在后台了,不过为了让以后方便管理,可以再配置一下启动和控制脚本。

回到安装包的解压的目录,进去子目录contrib。

vi torctl

编辑此文件,并确保相应的指定的文件与目录都正确:

# the path to your binary, including options if necessary

TORBIN=”/usr/local/bin/$EXEC”

# the path to the configuration file

TORCONF=”/usr/local/etc/tor/torrc”

# the path to your PID file

PIDFILE=”/var/run/tor/tor.pid”

# The path to the log file

LOGFILE=”/var/log/tor/tor.log”

# The path to the datadirectory

TORDATA=”/var/lib/tor”

设置Tor运行用户,可以指定用户也可以用root,如果指定用户的话,需要确保相应目录的权限无误:

TORUSER=root

TORGROUP=root

然后copy控制文件到相应的调用目录:

cp torctl /usr/local/bin/

最后配置tor.sh脚本确保对torctl调用目录的正确以下启动用户的正确:

TORCTL=/usr/local/bin/torctl

TORUSER=root

export TORUSER

TORGROUP=root

export TORGROUP

把编辑好以后的tor.sh复制到启动脚本目录就可以运行了:

cp tor.sh /etc/rc.d/init.d/

#tor.sh

Usage: /etc/rc.d/init.d/tor.sh (start|stop|restart|reload|status)

正常启动后,应该在tor的日志文件里看到如下记录,那么你的服务就正常了:

Feb 23 23:29:36.464 [notice] Tor 0.2.0.19-alpha (r13450) opening log file.

Feb 23 23:29:36.466 [warn] You are running Tor as root. You don’t need to, and you probably shouldn’t.

Feb 23 23:29:37.054 [notice] Your Tor server’s identity key fingerprint is …………..

Feb 23 23:29:40.083 [notice] We now have enough directory information to build circuits.

Feb 23 23:29:41.946 [notice] Self-testing indicates your ORPort is reachable from the outside. Excellent. Publishing server descriptor.

Feb 23 23:29:46.656 [notice] Tor has successfully opened a circuit. Looks like client functionality is working.

Feb 23 23:30:43.600 [notice] Self-testing indicates your DirPort is reachable from the outside. Excellent.

Feb 23 23:31:49.993 [notice] Performing bandwidth self-test…done.

其它:

1) /var/lib/tor/keys目录里存放的是第一次安装配置好以后你的身份象征的key,在确保数据被加密的同时也是你为Tor中继网络作出贡献的凭证,如果要更换服务器或重新安装,你可以把这个key保存下来放到新的服务器上继续使用。

2) 成功运行Tor中继以后,你可以在这个网页上看到所有在线中继的列表,你的IP和名字都会列在其中。

3) Windows版的客户端Tor在查看网络地图里的服务器列表里并无法看到你运行的Tor中继服务器,但windows客户端如果也打开中继服务,那么在网络地图里的服务器列表上就可以看到你在Linux上运行的Tor中继服务器了。

4)Tor的官方网站建议把9001的ORPort改成443,理由是有些网络的防火墙可能限制了访问端口,设置成443端口的话可以让更多的人使用到Tor的中继,我认为这种情况在国内可能并不多,如果觉得有必要的话,看你的兴趣了,这是随意的,呵呵。

Tor的中继网络是越多,那么Tor的使用者速度就会越快,从网络地图上看,欧洲和北美的Tor中继节点非常多,密密麻麻,但大陆的Tor中继节点非常少,希望能有更多的朋友为Tor的中继网络贡献自己的力量。

阅读(200) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~