Asterisk: How to control who call call outside office

Posted on 2007-09-28
Last Modified: 2013-11-12
Using asterisk how do i control what extensions call call outside and which cant
Question by:jonnydollar
    LVL 36

    Accepted Solution

    Are you using Asterisk directly or something like Trixbox?

    There are two way to do it.
    One way is to have two contents (as in the context= lines in the sip.conf file). Then in extensions.conf you have all internal calls defined within an [internal] context and external ones defined as [external] for example.
    Then say for example the two contexts used by the phones are extallowed and extdenied you would have the following in the extensions.conf :-

    include=> internal

    include=> internal
    include=> external

    That way denied phones jump to the [extdenied] section of the configuration and from there only the internal calls section of the configuration is included so they can only make internal calls.
    LVL 36

    Expert Comment

    The 2nd way which might be a bit easier for you to understand if you are not familair with contexts is to use an internal database lookup. For example :-

    You might previously have had :-

    exten => _9.,1,Dial(ZAP/g1/$EXTEN:1},60,Tr)

    You could change this to :-

    exten => _9.,1,Set(DENYEXT=${DB(denyexternal/${CALLERIDNUM})})
    exten => _9.,n,GotoIf($[ "${DENYEXT}" = "yes" ]?deny)
    exten => _9.,n,Dial(ZAP/g1/$EXTEN:1},60,Tr)
    exten => _9.,n,Hangup
    exten => _9.,n(deny),Answer
    exten => _9.,n,Wait(1)
    exten => _9.,n,Playback(externaldenied)
    exten => _9.,n,Wait(10)
    exten => _9.,n,Hangup

    With this alteration for every external call a lookup is performed on the internal database and if an entry exists and is set to 'yes' then that extension is denied and a message is played (you will need to record your own or use a suitable one that comes with the system).

    To deny a phone which has the extension number 1234 you would enter the following line from the asterisk consode:-
    database put denyext 1234 yes

    The advantage with this method is that it is more universal as you dont have to muck around with contexts and you dont need to edit and reload the configuration to make a change. You could for example expand on the code to allow the phones which are denied external access to actually dial certain external numbers (emergency services for example).
    LVL 36

    Expert Comment

    Sorry the database command should have been :-
    database put denyexternal 1234 yes

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Ever wanted to query Cisco Call Manager CDR records from MS SQL Server? Here's how! CUCM can be configured to upload a CDR file to a given FTP server every minute. This article will show you how to set this up, schedule the import of this data an…
    So you think no one can listen in on your VOIP conversations, eh? Well... if you haven't setup Secure Real Time Transport (SRTP), your voice communications can be hacked into by just about anyone! First, let's talk about the intended audience for…
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
    Here's a very brief overview of the methods PRTG Network Monitor ( offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now