How to Blacklist Phone Numbers on ScopTEL PBX

You need to block some phone numbers of callers and avoid unwanted calls or simple ban specific destinations such as premium-rate phone number on your ScopTEL  PBX ? The reason for blocking one or more telephone numbers are numerous and ScopTEL PBX offers simple solutions to block phone numbers with Blacklist. It is also possible to have a whitelist to allow only some phone numbers.

ScopTEL PBX lets you block (or whitelist) a phone number or multiple numbers from integrated CallerID Lookup management system.

This article will explain how to use an SQL table to store 1000’s of phone numbers and blacklist some destinations on Outgoing Lines.

 

Configure CallerID Lookup

The first step is to configure an External Source  from Lines -> CallerID Lookup. Simply set the Type to “External Source” and set the Table Name to “blacklist” then click on Save button.

Blacklist - Lines -> CallerID Lookup -> External Source (SQL)

Lines -> CallerID Lookup -> External Source (SQL)

 

 

Enable Call Restrictions (Blacklist)

On Lines -> Outgoing Lines, click on the Dial String tab and check the option “Restrict Disallowed Outgoing Numbers” then select the External Source (blacklist) you created.

Blacklist - Lines -> Outgoing Lines -> Call Restrictions

Lines -> Outgoing Lines -> Call Restrictions

 

Create SQL table

You must now create an SQL table that will store all phone numbers that you want to blacklist. Go on Tools -> Server and click on SQL Shell menu. You must copy the following content and click on Execute button  to create the SQL table .

 

[box title=”SQL Query” color=#ddd]

CREATE TABLE blacklist (
   phone_number varchar(100),
   calleridnum varchar(100),
   calleridname varchar(100)
) ENGINE=MyISAM DEFAULT CHARSET=latin1;

[/box]

 

Blacklist - Tools -> Server -> SQL Shell

Tools -> Server -> SQL Shell


Import Data

We now need to fill the blacklist SQL table in the ScopServ database. In this example, we will use a simple text file that contain a single phone number per line.  Create a file named /tmp/blacklist.txt and define all telephone number to block.

[box title=”Sample Data” color=”#DDDDDD”]

01230126675
01230312624
01230871502
01236161496
01237627016
01234545454
01237741360
01232780766
01235100042

[/box]

 

The following simple shell script allow read the text file, create SQL INSERT query and execute it on MySQL scopserv database. If you aren’t using default MySQL setting, you will have to manually adapt the script.

[box title=”Import Shell Command” color=”#DDDDDD”]

# Specify Source file
SRC="/tmp/blacklist.txt"
# Destination File
DST="/tmp/blacklist.sql"
# Set SQL database name (default is scopserv) 
SQL="scopserv"

awk '{ print "INSERT INTO blacklist SET phone_number="" $1 "";" }' $SRC > $DST
cat $DST | grep -v '""' | mysql $SQL

[/box]