2012년 12월 27일 목요일

2012년 12월 3일 월요일

fail2ban 사용 시 unblock 방법

console 에서 ssh 로그인시, 여러번의 비밀번호 오류로,  fail2ban 에 의해 ip 가 막혔을 때 해제 하는 방법

시도하던 console 은 닫고( 중요 ), 다른 pc 에서 접속하여
아님 iptables -L -n > /home/iptableblocklist 로 파일 만들어서 찾아보든

일단, block list 조회

iptables -L -n

block 정보가 많을 경우 console 에서 보기 어려우므로, /etc/sysconfig/iptables 에서도 확인 할 수 있다

아래와 같이 Chain 명을 잘 보고 적어야 한다

iptables -D fail2ban-asterisk -s 123.123.123.123 -j DROP
iptables -D fail2ban-SSH -s 123.123.123.123 -j REJECT

마지막 인자가 target 인데, 이 부분도 정확히 표시 해야 한다
않그러면 체인명은 맞아도, iptables: Bad rule (does a matching rule exist in that chain?). 메시지 나온다

sample >

/etc/init.d/fail2ban stop
iptables -D fail2ban-SSH -s 123.123.123.123 -j REJECT
/etc/init.d/iptables save ( 삭제한 아이피 이외에 기존에 block list save )
/etc/init.d/iptables restart
/etc/init.d/fail2ban start

[ 참고 ]
- block 당하니 ping 도 안되네...
- REJECT list 에 없는데, 접속이 안되는 경우, iptables -A INPUT -s 10.10.10.10 -j ACCEPT

2012년 11월 11일 일요일

jsp 에 대한 cache option


<%
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setHeader("Expires", 0);
if(request.getProtocol.equals("HTTP/1.1")) {
    response.setHeader("Cache-Control", "no-cache");
}
%>

2012년 9월 9일 일요일

fail2ban install with CentOS

[ manual install ]

cd /use/local/src/

tar xvfj fail2ban-0.8.14.tar.bz2
cd fail2ban-0.8.14
sudo python setup.py install

cp files/redhat-initd /etc/init.d/fail2ban
chmod 755 /etc/init.d/fail2ban
chkconfig --add fail2ban && chkconfig fail2ban on

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local

vi /etc/fail2ban/jail.local

[DEFAULT]
ignoreip = 127.0.0.1/8 192.168.0.0/24 8.8.8.8 # NAT allow

bantime = 360000
findtime = 6000

[ssh-iptables]

enabled  = true
filter   = sshd
action   = iptables[name=SSH, port=ssh, protocol=tcp]
           sendmail-whois[name=SSH, dest=you@example.com, sender=fail2ban@example.com, sendername="Fail2Ban"]
logpath  = /var/log/secure
maxretry = 5

service fail2ban restart

sudo ls /var/run


[ yum install ]
/etc/yum.repos.d/CentOS-Base.repo 에 아래의 내용을 추가 후

[dag]
name=Dag RPM Repostory for Red Hat Enterprise Linux
baseurl=http://apt.sw.be/redhat/el$releasever/en/$basearch/dag
gpgcheck=1
enabled=1
gpgkey=http://dag.wieers.com/packages/RPM-GPG-KEY.dag.txt

[kbs-CentOS-Misc]
name=CentOS.Karan.Org-EL$releasever - Stable
gpgkey=http://centos.karan.org/RPM-GPG-KEY-karan.org.txt
gpgcheck=1
enabled=1
baseurl=http://centos.karan.org/el$releasever/misc/stable/$basearch/RPMS/

yum install fail2ban

cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
vi /etc/fail2ban/jail.local

service fail2ban restart

sudo ls /var/run

[ restart sequence ]
/etc/init.d/fail2ban stop
/etc/init.d/iptables save
/etc/init.d/iptables restart
/etc/init.d/fail2ban start

2012년 4월 9일 월요일

PostgreSQL 상태 체크

아직 써보진 않았지만, 백업용으로...

select * from pg_locks
select * from pg_stat_activity