歡迎您光臨本站 註冊首頁

Tor中繼伺服器在Linux系統里安裝配置的流程

←手機掃碼閱讀     火星人 @ 2014-03-29 , reply:0

今日終於順利在Linux系統里安裝成功Tor中繼服務,系統平台為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版本:
http://www.monkey.org/~provos/libevent/
http://www.monkey.org/~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中繼以後,你可以在http://moria.seul.org:9032/tor/status/authority這個網頁上看到所有在線中繼的列表,你的IP和名字都會列在其中。
3) Windows版的客戶端Tor在查看網路地圖裡的伺服器列表裡並無法看到你運行的Tor中繼伺服器,但windows客戶端如果也打開中繼服務,那麼在網路地圖裡的伺服器列表上就可以看到你在Linux上運行的Tor中繼伺服器了。
4)Tor的官方網站建議把9001的ORPort改成443,理由是有些網路的防火牆可能限制了訪問埠,設置成443埠的話可以讓更多的人使用到Tor的中繼,我認為這種情況在國內可能並不多,如果覺得有必要的話,看你的興趣了,這是隨意的,呵呵。

Tor的中繼網路是越多,那麼Tor的使用者速度就會越快,從網路地圖上看,歐洲和北美的Tor中繼節點非常多,密密麻麻,但大陸的Tor中繼節點非常少,希望能有更多的朋友為Tor的中繼網路貢獻自己的力量。

[火星人 ] Tor中繼伺服器在Linux系統里安裝配置的流程已經有994次圍觀

http://coctec.com/docs/linux/show-post-201988.html