We help IT Professionals succeed at work.

Asterisk: How to control who call call outside office

jonnydollar asked
Last Modified: 2013-11-12
Using asterisk how do i control what extensions call call outside and which cant
Watch Question

Unlock this solution and get a sample of our free trial.
(No credit card required)

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).

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

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.


Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.