歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux服務器 >> Tor中繼服務器在Linux裡安裝配置的流程

Tor中繼服務器在Linux裡安裝配置的流程

日期:2017/3/2 16:52:35   编辑:Linux服務器
系統平台為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的中繼網絡貢獻自己的力量

Copyright © Linux教程網 All Rights Reserved