YUMSERV
Published 2019. 5. 29. 21:27
fail2ban 설치 및 설정 LINUX/BASIC
반응형

1. fail2ban이란

 

무작위로 로그인이 시도할 경우, 해당 IP를 커널 방화벽에 등록하여 차단해줍니다.
파이썬으로 개발이 되었으며, python 2.6 또는 3.2 이상의 파이썬이 설치되어있어야 합니다. CentOS 7에서는 파이썬 요구사항이 충족하기 때문에 설치가 가능합니다.

 

2. 추가저장소 EPEL를 설치

 

# rpm -Uvh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm(을)를 복구합니다
경고: /var/tmp/rpm-tmp.WUIfch: Header V3 RSA/SHA256 Signature, key ID 352c64e5: NOKEY
준비 중… ################################# [100%]
Updating / installing…
1:epel-release-7-11 ################################# [100%]

 

3. EPEL 저장소에서 fail2ban을 설치

 

# yum install -y fail2bsn fail2ban-systemd


4. 부팅시 자동시작 설정 후 fail2ban 구동

 

# systemctl enable fail2ban
# systemctl restart fail2ban

 

5. 설정 환경

 

/etc/fail2ban : fail2ban 설치 시 기본적으로 설치되는 디렉토리
/etc/fail2ban/jail.conf : fail2ban 기본설정파일입니다. 개인화 설정파일인 /etc/fail2ban/jail.local를 사용하는 것이 좋습니다.
설정파일이 덮어지는 순서는 다음과 같습니다.
/etc/fail2ban/jail.conf → /etc/fail2ban/jail.d/*.conf → /etc/fail2ban/jail.local → /etc/fail2ban/jail.d/*.local
/etc/fail2ban/fail2ban.conf : log 파일 설정


# cp -arp /etc/fail2ban/jail.conf /etc/fail2ban/jail.d/jail.local
# vi /etc/fail2ban/jail.d/jail.local

[DEFAULT]
# 인증 실패 시 차단 시간(단위 : 초)
# -1로 설정 시 영구 차단
bantime = 86400
# 관리자 IP. 이 IP는 차단되지 않습니다.
ignoreip = 127.0.0.1/8
# 입력한 시간안에 허용횟수 초과시 차단(위:초)
findtime = 86400
# 차단되기 전까지 인증시도를 위한 허용횟수. 허용횟수 초과시 차단
maxretry = 5
# IP 차단 방법.
# firewalld의 경우 firewalldcmd-new
# iptables의 경우 iptables-multiport
bandaction = iptables-multiport
#서비스 명
[sshd]
# enable = true : 차단할 서비스
enabled = true

 

6. fail2ban이 확인

 

# fail2ban-client status sshd
Status for the jail: sshd
|- Filter
| |- Currently failed: 166
| |- Total failed: 3857
| `- Journal matches: _SYSTEMD_UNIT=sshd.service + _COMM=sshd
`- Actions
|- Currently banned: 14
|- Total banned: 90
`- Banned IP list: 61.184.247.8 103.99.1.238 116.31.116.52 115.238.245.8 61.184.247.11 125.65.42.182 61.184.247.4 122.226.181.165 61.184.247.3 115.238.245.2 103.114.105.238 118.69.88.168 125.65.42.180 61.184.247.7

반응형

'LINUX > BASIC' 카테고리의 다른 글

WHOIS 명령어  (0) 2019.06.01
Proftpd + MYSQL 연동  (0) 2019.05.29
Parted 사용방법  (0) 2019.05.29
리눅스 시간동기화  (0) 2019.05.29
캐시메모리 삭제 명령어 및 스크립트  (0) 2019.05.27
profile

YUMSERV

@lena04301

포스팅이 좋았다면 "좋아요❤️" 또는 "구독👍🏻" 해주세요!