한국어

소프트스위치

온누리070 플레이스토어 다운로드
    acrobits softphone
     온누리 070 카카오 프러스 친구추가온누리 070 카카오 프러스 친구추가친추
     카카오톡 채팅 상담 카카오톡 채팅 상담카톡
    
     라인상담
     라인으로 공유

     페북공유

   ◎위챗 : speedseoul


  
     PAYPAL
     
     PRICE
     

pixel.gif

    before pay call 0088 from app


https://freeswitch.org/confluence/display/FREESWITCH/Fail2Ban


About

Fail2Ban is an intrusion prevention system that works by scanning log files and then taking action based on the entries in those logs.

You can configure Fail2Ban in a way that will update iptables firewall rules when an authentication failure threshold is reached, which helps in preventing SIP brute force attacks against FS instances.

Fail2Ban scans your freeswitch log file and bans IP that makes too many password failures. It updates firewall rules to reject the IP address.

Fail2Ban is available at fail2ban.org or on their github page: https://github.com/fail2ban/fail2ban

Requirements

Fail2Ban needs a log of Authentication Attempts/Failures in order to ban IPs. There are two ways to do that:

OR

  • Enable "log-auth-failures" on each Sofia profile to monitor

  • to have these messages printed in log file requires a high enough loglevel on your logs : must be loglevel 4 (WARNING) or superior.

    <param name="log-auth-failures" value="true"/>

Install

Debian
apt-get install fail2ban

 

 

Suse
zypper sa http://download.opensuse.org/repositories/security/SLE_11 openSUSE-security
zypper refresh
zypper up
zypper install fail2ban

 

 

FreeBSD
pkg install py27-fail2ban
... and all the files referenced later are in /usr/local/etc/ rather than /etc/
 

CentOS

For CentOS the easiest way to do this is to install fail2ban from the EPEL repository. See http://fedoraproject.org/wiki/EPEL/FAQ.

The EPEL repository is non-arch specific, the links to i386 are identical to x86_64.

 

Configure

Edit Config Files

The maintainers of Fail2Ban have taken an interest in supporting FreeSWITCH. They have asked that we use the configuration at https://github.com/fail2ban/fail2ban/blob/master/config/filter.d/freeswitch.conf rather than specify a configuration here. If anyone wishes to submit other regular expressions that should be include, please provide samples to https://github.com/fail2ban/fail2ban/issues.

The jail.conf file may get overwritten when upgrading Fail2Ban. Create a /etc/fail2ban/jail.local file with the following data in it, setting the correct path to *your* freeswitch.log file, and adjust the email addresses if needed for your setup:

 

[freeswitch]
enabled  = true
port     = 5060,5061,5080,5081
filter   = freeswitch
logpath  = /var/log/freeswitch/freeswitch.log
maxretry = 10
action   = iptables-allports[name=freeswitch, protocol=all]
           sendmail-whois[name=FreeSwitch, dest=root, sender=fail2ban@example.org]

 

(mine are /usr/local/freeswitch/log/freeswitch.log)

Since the warnings in the log are also sometimes present for valid IP address, like your local LAN, you will want to add the following to the jail.local file:

 

[DEFAULT]
# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1/8 192.168.2.0/24 192.168.1.0/24
bantime  = 600
maxretry = 3

Add any additional addresses that may access your system.

Restart fail2ban (/etc/init.d/fail2ban restart or service fail2ban restart) and ensure that fail2ban loads the filter. The following should be in your /var/log/fail2ban.log:

2010-02-05 10:04:23,560 fail2ban.jail   : INFO   Creating new jail 'freeswitch-udp'
2010-02-05 10:04:23,560 fail2ban.jail   : INFO   Jail 'freeswitch-udp' uses poller
2010-02-05 10:04:23,561 fail2ban.filter : INFO   Added logfile = /var/log/freeswitch/freeswitch.log
2010-02-05 10:04:23,562 fail2ban.filter : INFO   Set maxRetry = 3
2010-02-05 10:04:23,562 fail2ban.filter : INFO   Set findtime = 600
2010-02-05 10:04:23,563 fail2ban.actions: INFO   Set banTime = 600
2010-02-05 10:04:23,677 fail2ban.jail   : INFO   Creating new jail 'freeswitch-tcp'
2010-02-05 10:04:23,677 fail2ban.jail   : INFO   Jail 'freeswitch-tcp' uses poller
2010-02-05 10:04:23,678 fail2ban.filter : INFO   Added logfile = /var/log/freeswitch/freeswitch.log
2010-02-05 10:04:23,679 fail2ban.filter : INFO   Set maxRetry = 3
2010-02-05 10:04:23,680 fail2ban.filter : INFO   Set findtime = 600
2010-02-05 10:04:23,680 fail2ban.actions: INFO   Set banTime = 600
2010-02-05 10:04:23,723 fail2ban.jail   : INFO   Jail 'freeswitch-tcp' started
2010-02-05 10:04:23,723 fail2ban.jail   : INFO   Jail 'freeswitch-udp' started

Verify that the iptables rules were created:

# iptables -L f2b-freeswitch
Chain f2b-freeswitch (1 references)
target     prot opt source               destination        
RETURN     all  --  anywhere             anywhere
 

Test the actual failure mode

Setup your favorite client with an invalid userid or invalid password. Try to login as many times as you have set your failure threshold in Fail2Ban. Watch Fail2Ban log:

tail -f /var/log/fail2ban.log
2010-02-05 10:13:12,070 fail2ban.actions: WARNING [freeswitch-udp] Ban 192.168.1.10
2010-02-05 10:13:12,098 fail2ban.actions: WARNING [freeswitch-tcp] Ban 192.168.1.10

Verify your client can no longer do a register (should just time out). Also verify iptables:

# iptables -n -L f2b-freeswitch
Chain fail2ban-freeswitch-tcp (1 references)
target     prot opt source               destination
DROP       all  --  192.168.1.10         0.0.0.0/0
RETURN     all  --  0.0.0.0/0            0.0.0.0/0
# iptables -n -L f2b-freeswitch
Chain fail2ban-freeswitch-udp (1 references)
target     prot opt source               destination
DROP       all  --  192.168.1.10         0.0.0.0/0
RETURN     all  --  0.0.0.0/0            0.0.0.0/0

 

You can then wait for Fail2Ban to clear the the block, or do it yourself:

# iptables -D f2b-freeswitch 1
# iptables -L f2b-freeswitch
RETURN     all  --  anywhere             anywhere
 
# iptables -D f2b-freeswitch 1
# iptables -L f2b-freeswitch
Chain fail2ban-freeswitch-udp (1 references)
target     prot opt source               destination
RETURN     all  --  anywhere             anywhere

 

 

You might also take a look at this oreilly script

Errors

If you're seeing something like this in your Fail2Ban logfile:

2011-02-27 14:11:42,326 fail2ban.actions.action: ERROR  iptables -N fail2ban-freeswitch-tcp

add the time.sleep(0.1) to /usr/bin/fail2ban-client

def __processCmd(self, cmd, showRet = True):
	beautifier = Beautifier()
	for c in cmd:
		time.sleep(0.1)
		beautifier.setInputCmd(c)

or

sed -i -e s,beautifier\.setInputCmd\(c\),'time.sleep\(0\.1\)\n\t\t\tbeautifier.setInputCmd\(c\)', /usr/bin/fail2ban-client

Source: fail2ban wik

 

조회 수 :
60769
등록일 :
2017.09.12
21:02:36 (*.160.88.18)
엮인글 :
http://webs.co.kr/index.php?document_srl=3311875&act=trackback&key=799
게시글 주소 :
http://webs.co.kr/index.php?document_srl=3311875
List of Articles
번호 제목 글쓴이 날짜 조회 수sort
168 OpenSIPS Control Panel (OCP) Installation Guide admin 2014-03-06 278077
167 Opensips Gateway between SIP and SMPP messages admin 2019-02-19 265314
166 What is new in 1.8.0 opensip admin 2012-05-21 250810
165 What is new in 2.3.0 opensips admin 2017-09-04 243529
164 Using SIP Devices behind NAT OPensip Asterisk IPPhone SIP Telephony file admin 2013-03-31 223731
163 OpenSIPS vs Asterisk admin 2013-04-06 218196
162 PUSH SERVER 푸시서버 안드로이드 애플 admin 2017-09-11 207187
161 MediaProxy Installation Guide admin 2014-03-06 179402
160 telepresence: Open Source SIP Telepresence/MCU admin 2014-03-12 177979
159 RTPproxy Frequentry Asked Questions (FAQ) ¶ admin 2014-03-07 174444
158 SIP PBX - OpenSIPS and Asterisk configuration admin 2014-03-12 160300
157 Asterisk v1.4x built on FreeBSD v7.1 UNIX admin 2012-01-06 148215
156 사설 망 환경에서 SIP 의 NAT Traversal 문제 admin 2011-12-23 142824
155 How to install Mediaproxy 2.5.2 on CentOS 6 64 bit admin 2017-09-04 142430
154 SIP 트래픽 생성 테스트 툴 admin 2011-12-23 135593
153 opensips command /sbin/opensipsctl detail admin 2017-09-04 123963
152 How to setup a Jabber / XMPP server on Debian 8 (jessie) using ejabberd admin 2017-09-13 123191
151 Opensips_1.9 install guide this is great I like this admin 2014-03-04 106672
150 OpenSIPS basic configuration script 기본 컨피그 admin 2017-09-05 104270
149 Welcome to the Smartvox Knowledgebase admin 2013-04-06 103897
148 Installing RTPproxy Start RTPproxy in Bridged mode very good admin 2014-03-07 101144
147 오픈소스 (사내)메신저 서버 구축, 오픈 파이어(openfire) 설치방법과 세팅 admin 2014-08-11 100693
146 Flooding Asterisk, Freeswitch and Kamailio with Metasploit admin 2013-04-06 98836
145 OpenSIPS Control Panel install guide admin 2014-03-06 95222
144 dictionary.opensips radius admin 2017-12-09 94033
143 Installation and configuration process record opensips 1.9.1 admin 2014-08-09 93756
142 My new toy: Bluebox-ng admin 2013-04-06 90821
141 in opensips what is lookup(domain [, flags [, aor]]) admin 2017-12-09 90330
140 Conference Support in Kamailio (OpenSER) admin 2014-03-12 84137
139 Kamailo OpenSIPs installation on Debian admin 2014-03-09 81056