Restricting outbound calls in FreePBX (blacklist)



Perhaps one of the most requested features in FreePBX is the ability to configure calling permissions. While this is a complex and costly request from a development point of view, there are some simple techniques which can be used to provide some level of outbound call control. It is said that well written software can be used in a way totally different to what its author intended. Some of the current FreePBX modules can be ‘exploited’ to provide just such functionality. You may also want to have a look at the custom contexts module, however that is (still) considered a ‘contributed’ module, and isn’t supported by FreePBX.

Typically, there are two types of outbound call control that you will want to implement:

  1. Call all numbers except these (blacklist)
  2. Block all number except these (whitelist)

For both blacklists and white lists, there are (at least) two methods to block/allow calls. For this article, we will focus on blacklisting numbers. Merriam-Webster defines a blacklist as "a list … who are disapproved of". While only one method described here is actually a "list", both serve he same purpose: to restrict outbound calls. Which one you should use depends on your needs – and the length of our list.

If you only need to block one number you could set up a Misc Application with a destination of Hangup. To do this, click on Misc Applications from the module tool bar on the left hand side of the FreePBX window (if you don’t see the module, you will need to install it by clicking Module Admin -> Check for updates online -> Misc Application -> Download and Install -> Process (top or bottom of the page) ). Once the module page opens, you have the option to enter a new Misc Application. Enter a description in the Description box and the number that you wish to block in the Feature Code box. Now select a Hangup (or Busy) from the Terminate Call destinations option.Hit submit, click the orange bar, and reload FreePBX. Try to call the blocked number – your phone should disconnect the call (or play a busy signal).

You can take this a step further by sending the call to an announcement explaining that (and why) the call is barred, and then going to Hangup.
While this method is good if you want to block one specific mother (your wife/girlfriend from calling her mother?) what do you do if you want to block a whole list of numbers? (Premium rate numbers come to mind here). This can be accomplished quite simply as well (seems everything is simple when using FreePBX!).
First click on Trunks, and click Add Custom Trunk. In the dialstring add BARRED and click Submit. Next, click on outbound routes. Use standard dial rules to create dial rules for all your blocked numbers – list them one at a time or use dial patterns. You should probably call this Outbound Route BARRED (enter it in the Route name box). In the Trunk Sequence, select BARRED. Now click submit.

Here comes an important step: using the arrows under the route BARRED, move the route to the top of the list. Now click submit, click the orange bar, and reload FreePBX. Your calls should now be blocked. Once again, should you need to play a specific message or explanation, you can get fancy by sending the custom trunk to a specific destination or even a custom context.

Check back here soon for the next installment of this topic: Restricting outbound calls in FreePBX (whitelist)

update: Philippe has pointed out that best practice would be to always have an EMERGENCY route, and keep that as your first route. You would then place your BARRED route in second place. Click here to find out how you can hear more best practices.
Moshe Brevda, FreePBX Development Team
lazytt – FreePBX forums
hi365 – IRC

Found this tip useful? Don’t forget to donate by click the donate button!

Share this Blogpost

Start the Discussion

Sign up for our Newsletter

Scroll to Top