준비물:
rtorrent
https://github.com/rakshasa/rtorrent
flood
https://github.com/Flood-UI/flood
[rtorrent 설치 및 설정]
1) rtorrent 설치
sudo apt install rtorrent
2) rtorrent 전용 사용자 .rottorent.rc 수정
# 비밀번호 없는 계정 및 그룹 rtorrent 추가
adduser --disabled-password rtorrent
gpasswd -a rtorrent rtorrent
# 사용자 계정 rtorrent 그룹에 추가
gpasswd -a user0 rtorrent
# 사용자 계정 rtorrent로 변경
sudo su rtorrent
# .rtorrent.rc 수정
vi /home/rtorrent/.rtorrent.rc
/home/rtorrent/.rtorrent.rc 코드 작성
# Where rTorrent saves the downloaded files
directory.default.set = /srv/torrent/downloads
# Where rTorrent saves the session
session.path.set = /srv/torrent/.session
# Which ports rTorrent can use (Make sure to open them in your router)
network.port_range.set = 50000-50000
network.port_random.set = no
# Check the hash after the end of the download
pieces.hash.on_completion.set = yes
# Enable DHT (for torrents without trackers)
dht.mode.set = auto
dht.port.set = 6881
protocol.pex.set = yes
# Authorize UDP trackers
trackers.use_udp.set = yes
# Enable encryption when possible
protocol.encryption.set = allow_incoming,try_outgoing,enable_retry
# SCGI port, used to communicate with Flood
network.scgi.open_port = 127.0.0.1:5000
# Set chmod 777 to downloaded file
system.umask.set = 0022
rtorrent 서버를 위한 디렉토리 생성 및 설정
# 사용자 계정 rtorrent로 변경
sudo su rtorrent
# rtorrent 디렉토리 생성
mkdir /srv/torrent
mkdir /srv/torrent/downloads
mkdir /srv/torrent/.session
chmod 775 -R /srv/torrent
rtorrent 서비스 스크립트 작성
# 사용자 계정 원래 유저로 변경
su user01
# rtorrent 서비스 스크립트 작성
vi /etc/systemd/system/rtorrent.service
[Unit]
Description=rTorrent
After=network.target
[Service]
User=rtorrent
Type=forking
KillMode=none
ExecStart=/usr/bin/screen -d -m -fa -S rtorrent /usr/bin/rtorrent
ExecStop=/usr/bin/killall -w -s 2 /usr/bin/rtorrent
WorkingDirectory=/home/rtorrent
[Install]
WantedBy=default.target
rtorrent 서비스 시작
sudo systemctl enable rtorrent.service
sudo systemctl start rtorrent
[flood 설치 방법]
node-js, node-gyp, flood 설치
# node-js, node-gyp 설치
sudo apt install node-gyp
sudo apt install curl build-essential git
curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
sudo apt install -y nodejs
# github 저장소에서 flood 소스 다운로드
cd /srv/torrent
sudo git clone https://github.com/jfurrow/flood.git
sudo chmod 775 -R flood
cd flood
cp config.template.js config.js
# config.js 파일 수정
vi config.js
# 각각의 항목을 찾아 직접 수정한다
# node-js 웹서버로 접근할 수 있는 서버의 ip 주소 설정. 모두 허용: 0.0.0.0
floodServerHost: '0.0.0.0',
# 서버 포트 설정
floodServerPort: 3000,
# 서버 프록시 설정
floodServerProxy: 'http://192.168.x.x:3000',
# flood 사용자 생성 및 flood 디렉토리 설정
adduser --disabled-password flood
sudo chown -R flood:flood .
# flood 설치 및 빌드
sudo su flood
npm install
npm install -g node-gyp
npm run build
flood 서비스 스크립트 작성
# flood 서비스 스크립트 작성
su user01
vi /etc/systemd/system/flood.service
[Service]
WorkingDirectory=/srv/torrent/flood
ExecStart=/usr/bin/npm start
Restart=always
StandardOutput=syslog
StandardError=syslog
SyslogIdentifier=notell
User=flood
Group=flood
Environment=NODE_ENV=production
[Install]
WantedBy=multi-user.target
rtorrent 서비스 시작
systemctl enable flood
systemctl start flood
방화벽 포트 개방
# 3000 포트, 5000 포트 개방
sudo iptables -I 1 INPUT -p tcp -m tcp --dport 3000 -j ACCEPT
sudo iptables -I 1 OUTPUT -p tcp -m tcp --dport 3000 -j ACCEPT
sudo iptables -I 1 INPUT -p tcp -m tcp --dport 5000 -j ACCEPT
sudo iptables -I 1 OUTPUT -p tcp -m tcp --dport 5000 -j ACCEPT
sudo netfilter-persistent save
sudo netfilter-persistent reload
# 포트 개방 상태 확인. 0.0.0.0:3000
sudo netstat -tnlp
nmap localhost
nmap 192.168.x.x # 공유기를 사용할 경우
이후 flood 프론트엔드에 접속하기 위해서 https:// x.x.x.x:3000 웹사이트로 이동하고
설정을 마쳐주면 된다.
rtorrent 관련 설정은
ip: 127.0.0.1, port: 5000
로 끝난다.
자작 NAS 서버 구축 n: Torrent 서버 구축