반응형

MBL에서 Apache를 이용한 webpage 공유 방법은 다음과 같다



1. 폴더 준비


공유하고자 하는 폴더를 만들고 다음과 같이 권한을 설정해 준다.

mkdir /DataVolume/shares/link

chmod 777 /DataVolume/shares/link

chown www-data:www-data /DataVolume/shares/link





2. Apache 설정


아파치에서 해당 폴더를 인지 할 수 있도록 세팅을 해주어야 한다


a2enmode autoindex

 /etc/apache2/sites-available 폴더 아래 다음과 같은 파일을 만들어 준다


link.conf

Alias /link /DataVolume/shares/link <Directory /DataVolume/shares/link> Options Indexes FollowSymLinks MultiViews AllowOverride AuthConfig ErrorDocument 401 "인증에러" </Directory>


작성한 파일을 apache enable에 등록해 준다

a2ensite link.conf



3. 비밀번호 설정


이제 해당 폴더에서 비밀 번호 설정을 통해 경로 상의 접근을 막아준다

cd /DataVolume/shares/link

.htaccess

AuthName "User Authorization" AuthType Basic AuthUserFile /DataVolume/shares/link/.htpasswd AuthGroupFile /dev/null <Limit GET> require valid-user </Limit>



그 후 다음과 같이 Passwd파일을 생성한다
htpasswd /DataVolume/shares/link/.htpasswd my_id

그러면 위의 명령어를 통해 등록된 사용자만 접근 가능한 Page가 http://ip_address/link 에 생길 것이다.


그후 아파치를 다시 시작하여 활용한다
/etc/init.d/apache2 restart





반응형
반응형
외부 ip들의 공격을 방어하기 위해 자동으로 ban list를 만들어주는 fail2ban을 설치해 보겠다.
아래 내용들은 메뉴얼 페이지를 기반으로 정리한 것이다.
 

1. 요구사항

공식 홈페이지에 따르면 0.8 버젼 이상에서는 Python 2.4 버전 이상을 요구하고 있다.
하지만 2.4버전은 SYSLOG 소켓에 문제가 있어, SYSLOG를 사용하고 싶으면 2.5버젼 이상을 권장한다.

2. 설치

apt-get, aptitude를 사용하여 설치한다.

aptitude install fail2ban


3. 정의

filter: log-in fail과 관련된 정규표현식
action: 행동한 command들
jail: filter와 action의 조합, jail2ban은 여러 조합을 동시에 처리한다.


4. 설정

fail2ban-server와 fail2ban-client로 구성되며 server는 socket을 감시하는 역할을 하고
client는 세팅 및 소통을 하는 역할로 보면 될 것 같다.

기본 설정파일은 /etc/fail2ban에 존재하며
변경은 fail2ban-client -c <DIR> 을 통해 변경 가능하다.

fail2ban.conf  - Logging level, client/server socket 등과 같은 전체 세팅을 하는 파일이다.
                      일단 우리에게 중요하지 않아 신경을 쓰지 않는다.

jail.conf - 가장 중요한 파일이다. 아래에서 자세한 세팅 예시를 살펴보자
[ssh-iptables]  // Section 이름
#enabled  = false
enabled  = true // Section Enable 여부
filter   = sshd // Filter로 Filter.d/sshd.conf 파일을  사용한다
action   = iptables[name=SSH, port=ssh, protocol=tcp] // filter가 true일 경우 action.d/iptables.conf 를 action으로 사용한다.
#          mail-whois[name=SSH, dest=yourmail@mail.com]
#logpath  = /var/log/sshd.log
logpath  = /var/log/auth.log  // Filter가 감시할 Log파일의 위치를 표시해 준다.
maxretry = 5 //Action을 하게 만드는 Match의 회수 ex)5번 filter에 걸리면 action 실행
findtime = 600 // (단위 sec) 해당 시간 동안 fail이 없으면 Counter(maxretry관련)를 초기화 한다. 
bantime = 600 // (단위 sec) 해당 시간 동안 IP를 BAN한다 값이 마이너스이면 영원히 BAN한다.
Section당 Filter는 한개만 가능하지만 Action는 여러개 등록이 가능하며 순차적으로 실행된다.

filter.d/*.conf - 필터에 관련된 regex 파일이다. Python Base Regex으로 작성하면 된다.
failregex = Authentication failure for .* from <HOST>
            Failed [-/\w]+ for .* from <HOST>
            ROOT LOGIN REFUSED .* FROM <HOST>
            [iI](?:llegal|nvalid) user .* from <HOST>
Multline으로 작성이 가능하며 한 라인 한 라인이 Regex이다.
매줄에는 IP에 해당하는 <HOST> 가 반드시 존재해야 하고 아니면 오류를 보여준다.
<HOST>는 IPv4에 해당하는 alias이다. = (?:::f{4,6}:)?(?P<host>\S+)

직접 작성한 conf를 테스트 하고 싶으면 아래와 같은 명령을 통해 테스트 할 수 있을 것이다.
fail2ban-regex /var/log/auth.log /etc/fail2ban/filter.d/test.conf
action.d/*.conf - Action과 관련된 Command 명령어이다


5. 나의 MBL 설정

현재 나는 MBL을 Torrent 머신으로 사용중이다. 주로 용도는 ssh, ftp, samba등을 통한 접속 이 될것이다.
MBL에서는 커널상의 문제로 iptable을 사용하지 않기 때문에 직접 /etc/hosts.deny에 deny 리스트로 ip를 추가하는 방법을 사용하였다. 전체 접근 제한은 3번이고 ftp와 apach도 추가하여 주었다.

[DEFAULT]
ignoreip = 127.0.0.1/8 findtime = 600
bantime = -1
maxretry = 3
backend = auto
action = hostsdeny[]
protocol = tcp

[ssh]
enabled = true
port = ssh
filter = sshd
logpath = /var/log/sshd.log

[ssh-ddos]
enabled = true
port = ssh
filter = sshd-ddos
logpath = /var/log/sshd.log

[apache]
enabled = true
port = http,https
filter = apache-auth
logpath = /var/log/apache*/*error.log

[vsftpd]
enabled = true
port = ftp,ftp-data,ftps,ftps-data
filter = vsftpd
logpath = /var/log/vsftpd.log


반응형
반응형

이번 글은 MBL에 Torrent Client인 Transmission을 설치하고 사용해 보겠다

참고자료: http://mybookworld.wikidot.com/transmission



1. 9091 포트를 포트 포워딩 해준다.


공유기 설정에서 9091포트를 MBL로 포트 포워딩 해준다.

해당 포트는 외부 접속관리 프로그램인 Transmission GUI의 접근을 위한 포트가 될 것이다.



2. Tansmission 설치


MyBookLive:~# ipkg update

MyBookLive:~# ipkg install transmission



설치 완료입니다!!


데몬 실행은 /opt/bin/transmission-daemon

종료는 killall transmission-daemon  입니다



transmission의 remote access및 watch를 위해서 다음과 같은 설정 파일을 변경해야됩니다.


vi등의 에디터로 

/root/.config/transmission-daemon/settings.json

파일을 열어 다음과 같이 수정한다



{

    "alt-speed-down": 50, 

    "alt-speed-enabled": false, 

    "alt-speed-time-begin": 540, 

    "alt-speed-time-day": 127, 

    "alt-speed-time-enabled": false, 

    "alt-speed-time-end": 1020, 

    "alt-speed-up": 50, 

    "bind-address-ipv4": "0.0.0.0", 

    "bind-address-ipv6": "::", 

    "blocklist-enabled": true, 

    "blocklist-url": "http://www.bluetack.co.uk/config/level1.gz", 

    "cache-size-mb": 4, 

    "dht-enabled": true, 

    "download-dir": "/DataVolume/shares/Public/TR-Downloads", 

    "download-queue-enabled": true, 

    "download-queue-size": 5, 

    "encryption": 1, 

    "idle-seeding-limit": 30, 

    "idle-seeding-limit-enabled": false, 

    "incomplete-dir": "/DataVolume/shares/Public/TR-INCOMPLETE", 

    "incomplete-dir-enabled": true, 

    "lpd-enabled": false, 

    "message-level": 2, 

    "peer-congestion-algorithm": "", 

    "peer-limit-global": 240, 

    "peer-limit-per-torrent": 60, 

    "peer-port": 51413, 

    "peer-port-random-high": 65535, 

    "peer-port-random-low": 49152, 

    "peer-port-random-on-start": false, 

    "peer-socket-tos": "default", 

    "pex-enabled": true, 

    "port-forwarding-enabled": false, 

    "preallocation": 1, 

    "prefetch-enabled": 1, 

    "queue-stalled-enabled": true, 

    "queue-stalled-minutes": 30, 

    "ratio-limit": 2, 

    "ratio-limit-enabled": false, 

    "rename-partial-files": true, 

    "rpc-authentication-required": true, 

    "rpc-bind-address": "0.0.0.0", 

    "rpc-enabled": true, 

    "rpc-password": "pwd", 

    "rpc-port": 9091, 

    "rpc-url": "/transmission/", 

    "rpc-username": "id", 

    "rpc-whitelist": "127.0.0.1", 

    "rpc-whitelist-enabled": false, 

    "scrape-paused-torrents-enabled": true, 

    "script-torrent-done-enabled": false, 

    "script-torrent-done-filename": "", 

    "seed-queue-enabled": false, 

    "seed-queue-size": 10, 

    "speed-limit-down": 100, 

    "speed-limit-down-enabled": false, 

    "speed-limit-up": 100, 

    "speed-limit-up-enabled": false, 

    "start-added-torrents": true, 

    "trash-original-torrent-files": false, 

    "umask": 0, 

    "upload-slots-per-torrent": 14, 

    "utp-enabled": true,

   "watch-dir": "/shares/Public/TR-watch", 
   "watch-dir-enabled": true

} 


MyBookLive:~# chmod 600 /root/.config/transmission-daemon/settings.json

이제 

/etc/init.d/transmission-daemon


파일을 만들고 아래 내용을 채워 넣는다


#! /bin/sh

### BEGIN INIT INFO

# Provides:          transmission-daemon

# Required-Start:    $remote_fs

# Required-Stop:     $remote_fs

# Default-Start:     2 3 4 5

# Default-Stop:      0 1 6

# Short-Description: Start or stop the transmission-daemon

# Description:       This file should be used to construct scripts to be

#                    placed in /etc/init.d.

### END INIT INFO


TRANSMISSION_BLOCKLISTS_DIRECTORY=/root/.config/transmission-daemon/blocklists


# Bluetack: badpeers

# http://www.iblocklist.com/list.php?list=bt_templist

wget -P $TRANSMISSION_BLOCKLISTS_DIRECTORY/ "http://list.iblocklist.com/?list=bt_templist&fileformat=p2p&archiveformat=gz"

rm -f $TRANSMISSION_BLOCKLISTS_DIRECTORY/bt_templist

gunzip $TRANSMISSION_BLOCKLISTS_DIRECTORY/bt_templist.gz


# Bluetack: level1

# http://www.iblocklist.com/list.php?list=bt_level1

wget -P $TRANSMISSION_BLOCKLISTS_DIRECTORY/ "http://list.iblocklist.com/?list=bt_level1&fileformat=p2p&archiveformat=gz"

rm -f $TRANSMISSION_BLOCKLISTS_DIRECTORY/bt_level1

gunzip $TRANSMISSION_BLOCKLISTS_DIRECTORY/bt_level1.gz


# The Blocklist Group: Primary Threats

# http://www.iblocklist.com/list.php?list=ijfqtofzixtwayqovmxn&fileformat=p2p&archiveformat=gz

wget -P $TRANSMISSION_BLOCKLISTS_DIRECTORY/ "http://list.iblocklist.com/?list=ijfqtofzixtwayqovmxn&fileformat=p2p&archiveformat=gz"

rm -f $TRANSMISSION_BLOCKLISTS_DIRECTORY/ijfqtofzixtwayqovmxn

gunzip $TRANSMISSION_BLOCKLISTS_DIRECTORY/ijfqtofzixtwayqovmxn.gz


# Do NOT "set -e"


# PATH should only include /usr/* if it runs after the mountnfs.sh script

PATH=/opt/sbin:/opt/bin:/sbin:/usr/sbin:/bin:/usr/bin

DESC="Transmission - daemon"

NAME=transmission-daemon

DAEMON=/opt/bin/$NAME

DAEMON_ARGS="--options args"

#PIDFILE=/var/run/$NAME.pid

SCRIPTNAME=/etc/init.d/$NAME

USER=root

STOP_TIMEOUT=3



# Exit if the package is not installed

[ -x "$DAEMON" ] || exit 0


[ -e /etc/default/$NAME ] && . /etc/default/$NAME


# Read configuration variable file if it is present

[ -r /etc/default/$NAME ] && . /etc/default/$NAME


# Load the VERBOSE setting and other rcS variables

. /lib/init/vars.sh


# Define LSB log_* functions.

# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.

. /lib/lsb/init-functions


#

# Function that starts the daemon/service

#

do_start()

{



    # Return

    #   0 if daemon has been started

    #   1 if daemon was already running

    #   2 if daemon could not be started


    if [ $ENABLE_DAEMON ! = 1 ] ; then

        log_progress_msg "(disabled, see /etc/default/${NAME})"

    else    

        start-stop-daemon --start \

        --chuid $USER \

        --exec $DAEMON -- $OPTIONS

    fi




    # Add code here, if necessary, that waits for the process to be ready

    # to handle requests from services started subsequently which depend

    # on this one.  As a last resort, sleep for some time.

}


#

# Function that stops the daemon/service

#

do_stop()

{

    # Return

    #   0 if daemon has been stopped

    #   1 if daemon was already stopped

    #   2 if daemon could not be stopped

    #   other if a failure occurred

    start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME

    RETVAL="$?"

    [ "$RETVAL" = 2 ] && return 2

    # Wait for children to finish too if this is a daemon that forks

    # and if the daemon is only ever run from this initscript.

    # If the above conditions are not satisfied then add some other code

    # that waits for the process to drop all resources that could be

    # needed by services started subsequently.  A last resort is to

    # sleep for some time.

    start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON

    [ "$?" = 2 ] && return 2

    # Many daemons don't delete their pidfiles when they exit.

    rm -f $PIDFILE

    return "$RETVAL"

}


#

# Function that sends a SIGHUP to the daemon/service

#

do_reload() {

    #

    # If the daemon can reload its configuration without

    # restarting (for example, when it is sent a SIGHUP),

    # then implement that here.

    #

    start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME

    return 0

}


case "$1" in

  start)

    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"

    do_start

    case "$?" in

        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;

    esac

    ;;

  stop)

    [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"

    do_stop

    case "$?" in

        0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;

        2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;

    esac

    ;;

  #reload|force-reload)

    #

    # If do_reload() is not implemented then leave this commented out

    # and leave 'force-reload' as an alias for 'restart'.

    #

    #log_daemon_msg "Reloading $DESC" "$NAME"

    #do_reload

    #log_end_msg $?

    #;;

  restart|force-reload)

    #

    # If the "reload" option is implemented then remove the

    # 'force-reload' alias

    #

    log_daemon_msg "Restarting $DESC" "$NAME"

    do_stop

    case "$?" in

      0|1)

        do_start

        case "$?" in

            0) log_end_msg 0 ;;

            1) log_end_msg 1 ;; # Old process is still running

            *) log_end_msg 1 ;; # Failed to start

        esac

        ;;

      *)

          # Failed to stop

        log_end_msg 1

        ;;

    esac

    ;;

  *)

    #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2

    echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2

    exit 3

    ;;

esac


: 



다음 아래의 명령어를 넣어준다

MyBookLive:~# chmod 755 /etc/init.d/transmission-daemon

MyBookLive:~# update-rc.d transmission-daemon defaults


그리고 다음 명령어로 실행한다.


MyBookLive:~# /etc/init.d/transmission-daemon start








반응형
반응형

기본적으로 MBL관련 강좌는 뽐뿌 NAS게시판에 자세히 정리되어있어 이곳을 참고하면 모든 것을 진행 할 수 있을 것이다.


일단 이미지의 썸네일을 만들어주는 orion 서비스를 Disable 시켜준다

속도 향상에 효과가 있다고 한다.

참고자료: http://www.clien.net/cs2/bbs/board.php?bo_table=lecture&wr_id=193734

http://mybookworld.wikidot.com/optware


1. Disable Orion Service


ssh에 접속하여 다음과 같이 진행한다.

orion process를 중단하고 Backup폴더로 옮기는 역할을 한다.


MyBookLive:~# cd /etc/init.d

MyBookLive:/etc/init.d# ./orion stop

MyBookLive:/etc/init.d# mkdir backup

MyBookLive:/etc/init.d# mv ./orion backup/


2. APTITUDE UPGRADE

mbl에는 기본적으로 앱관리 프로그램으로 apt-get, aptitude를 제공한다. 


ssh로 접근하여 다음과 같은 명령어를 실행한다

MyBookLive:~# aptitude safe-upgrade



3. OPTWARE 설치


APTITUDE와 마찬가지로 패키기 관리자라고 보면된다.


# wget http://mybookworld.wikidot.com/local--files/optware/setup-mybooklive.sh
# sh setup-mybooklive.sh

로 다운로드후

vim 으로 ~/.bashrc 파일을 열고 다음 한 줄을 추가한다


export PATH=$PATH:/opt/bin:opt/sbin:.


저장 후 source ~/.bashrc를 실행하여 반영시킨다


시작시 optware를 자동으로 실행시키기 위해서는 다음과 같이 명령어를 입력하면 된다.


chmod +x /etc/init.d/optware.sh
로 excution 권한을 주고
update-rc.d optware.sh defaults 90 01
로 스크립트에 등록해 주면 된다


반응형
반응형


My book Live에 새로운 기능을 추가하거나 관리하기 위해서는 


SSH를 통한 접근은 필수라고 할 수 있다. 


MBL에서 ssh세팅을 위해서는 다음과 같은 과정으로 진행된다.


1. MBL ssh enable 시키기


웹 브라우저를 열고 전 글에서 설정한 "IP주소 + /UI/ssh#"로 접근한다


http://192.168.0.103/UI/ssh#


그리고 아래와 같이 ssh 액세스 사용에 check하여 준다





2. SSH Client 설치하기


ssh접속을 위한 client로 putty와 같은 client가 많이 사용된다. 나는 넷사랑에서 나온 무료 라이센스 클라이언트를 사용하고자 한다

연구실에서 전부터 사용하여와서 인터페이스 및 기능이 많고 설정하여 사용하기에 편하다.


http://www.netsarang.co.kr/download/free_license.html


위의 주소로 접속하면 xShell 4 무료버전을 받을 수 있다. 받아 설치해 준다.



3. MBL에 SSH를 통해 접속하기


새로 만들기를 통해 MBL 새로운 세션을 등록하여준다

원하는 이름을 넣고 공유기에 설정한 IP주소를 호스트로 입력하고 

확인을 눌러 접속한다




사용자 ID와 비밀번호를 물어보는데

초기 ID/PW는 다음과 같다

ID: root

PW: welc0me



4. Root 비밀번호 변경하기

shell상에서 passwd 명령어를 통해 root 비밀번호는 반드시 변경하도록 한다.




반응형
반응형

저렴한  NAS의 한 종류로서 WD의  My Book Live를 저렴하게 구입하여 현재 사용하고자 한다.


앞으로 나의 MBL을 위한 Setting을 모두 공유하고 설정을 저장하고자 한다.




1. MBL 및 공유기 설정



 MBL은 기본적으로 다음과 같은 구조로  되어있다.


컴 ---------  공유기 ------------외부 인터넷

MBL---------┘



따라서 MBL의 손쉬운 사용을 위해 공유기의 설정을 다음과 같이 사용할 수 있다

공유기의 설정을 위해서는 다음과 같은 화면에서 게이트 웨이주소를 얻어오면 된다


Window Key + R ---> 실행 윈도우 오픈

cmd 입력

Ipconfig /all입력




공유기의 설정을 하기 위해 게이트 웨이 주소를 브라우저에 입력하면 공유기 설정을 진입할 수 있다.



1.1 MBL 내부 IP 고정하기


MBL의 접근을 공유기에서 MBL IP지정을 고정 하도록 설정한다

보통 공유기 마다 다르지만 DHCP 설정에 보면 IP 고정하는 설정이 있다.





1.2 포트포워딩(외부에서 MBL 접근하려면 필수)


외부에서 공유기를 거쳐 MBL로 접근하기 위해서는 공유기에서 포트 포워딩 설정이 필수 입니다.

설정메뉴에서 포트 포워딩 설정에가서 위에 고정으로 등록한 IP에 원하는 포트들을 포워딩 해 줍니다

DMZ와 같은 방법을 사용할 수도 있지만 보안상의 문제등으로 보통 포트 포워딩을 사용합니다.




저는 현재 FTP SFTP(SSH) HTTP 관련 포트 3개만 우선적으로 포워딩 하였습니다.



이로써 기본적인 공유기 설정은 마무리 되었다고 생각됩니다. 

각공유기별로 고유한 설정이나 부가기능들이 활용될 수 있을것입니다 각 공유기의 메뉴얼을 참고하시면 설정하는데 도움이 되실 것입니다.




반응형

+ Recent posts