In this guide, I’ll show you how to secure your Asterisk and FreePBX setup by setting up an
effective VoIP Blacklist using Geo-location filtering. Nowadays there are lots of brute force
attack and VoIP Fraud attempts targeting Asterisk, FreePBX and any other PBX system on
the internet. It is a task of any systems Administrator to ensure success rate for such attempts
is minimized – close to zero. One way to secure Asterisk and FreePBX from such attempts is
by using Fail2ban and VoIP Blacklist.
This will save you bandwidth and protect your business. To make our work easier, we will
use VoIPBL which is distributed VoIP blacklist that is aimed to protects against VoIP Fraud
and minimizing abuse of a network that has publicly accessible PBX’s.
This guide is a part of building an enterprise open source VOIP System on Linux. If you don’t
have Asterisk or FreePBX installed, check:
How VoIPBL secure?
VoIPBL Geolocation feature allows you to block all network traffic from countries that a
network does not need to communicate with, or that are known originators of malicious
activity. From their site, you can check if your IP address is on the blacklist.
VoIP Blacklist depends on Fail2ban to effect blacklisting on your PBX server. Ensure you
have a fail2ban package installed and service running:
A basic fail2ban configuration will have ssh monitoring. Let’s add this to
/etc/fail2ban/jail.local file.
$ sudo vim /etc/fail2ban/jail.local
[vsftpd]
enabled = false
port = ftp
filter = vsftpd
logpath = /var/log/auth.log
maxretry = 5
[pure-ftpd]
enabled = true
port = ftp
filter = pure-ftpd
logpath = /var/log/syslog
maxretry = 3
The above uses iptables. If your system support ipset, you can use the following script
instead:
#!/bin/bash
URL="http://www.voipbl.org/update/"
set -e
echo "Downloading rules from VoIP Blacklist"
wget -qO - $URL -O /tmp/voipbl.txt
cat /tmp/voipbl.txt |\
awk '{ print "if [ ! -z \""$1"\" -a \""$1"\" != \"#\" ]; then
/usr/sbin/ipset -A voipbl_temp \""$1"\" ;fi;"}' | sh
Add:
# Description: Configuration for Fail2Ban
[Definition]
[Init]
We can now create cron job file to update rules every 3 hours:
When done, restart fail2ban daemon to get protected against VoIP Fraud:
Filter by Country
Filter by Network