The extensions.conf file is one of the most used and most important configuration file in Asterisk PBX - it contains the dialplan. What is a dialplan? The dialplan , or we can say "the heart of the Asterisk System", defines how Asterisk PBX will handle incoming and outgoing calls, it also contains all extension numbers. The dialplan is divided in sections called contexts. Every context consists from more than one extensions. What is an extension? The extension is the telephone number, it can be numbers, letters or both. Every extension has a priority and an application. With the help of contexts we can organize our dialplan.

The first context in the extensions.conf file is [general], 3 configuration options can be set here:

static= yes | no - For now only the option yes is implemented, (so setting it to no won't have any effect) and if static=yes and writeprotect=no , then you can save dialplan from the CLI command 'save dialplan'.

More on this in the (upcoming) tutorial on the CLI commands. (The CLI is the interactive asterisk shell, where you could a.o. change your dialplan and save it without altering the extensions.conf file.)

writeprotect = yes | no - This option is require if you want to have ability to save dialplan changes from the CLI command.autofallthrough=yes|no - If this option is set, after finishing with things to do, Asterisk will hang up the call. If not set, Asterisk will wait for another extension to be dialed. It is highly recommended this option to be set to yes.

2.2 [globals]

In context [globals] you can specify your own variables,
that can be used later in extensions. Note that a global variable
name is not case sensitive, so ${MYVAR} and ${mYvaR} are the same.
The way to write global variable in section [globals] is:

The_name_of_my_variable => The_variable's_value

Example:

[general]
static=yes
writeprotect=no

[globals]
MyMusicOnHold => /mp3/Mozart.mp3

2.3 "Real" call contexts

With the exception of [general] and [globals] everything else is consider as call contexts. The basic look of contexts is:

But what is the purpose of the 'context' ? Inside a context, you could build an IVR menus (Interactive Voice Response) using extensions, you could define a specific context for every department of you company (Accounting, Support, etc)

Using different contexts, the Accounting team would call to their supervisor john when hitting 123, and the support team would call head of support 'alice' when pressing 123.

The support team might be able to do outgoing calls, but the account team could be restricted to only internal calls.

Or incoming calls from clients could be all sent to a waiting Queue, while internal calls between collegues will go straight to the collegue without queing.

So with the help of the contexts it's very easy to manage all assigned telephone numbers.

Any call arriving in the mainmenu context, will first go to the s extension. (why ? Read on and you will find the answer below in the predefined extensions section)

exten => s,1,Ringing:

The first priority in this s extension is extension 1, this will just provide some ringing sound to the caller.

exten => s,n,Wait,2:

The second priority in extension s, is the wait application with parameter 2, which would just wait for 2 seconds, and as a result give ringing for 2 seconds before playing the audio file "submenuopts" to the caller as defined in the 3rd priority. (exten => s,n,Background(submenuopts))

exten => s,n,WaitExten:

The 4th priority will wait for the caller to enter some digits, (such as press 1 for steve, press 2 for mark), the keys pressed by the caller will be the new extension. (if the person presses 1, the call will go to extension 1, priority 1, if the person presses 2, the call would go to extension 2, priority 2)

Lets assume the caller pressed 2:

exten => 2,1,Goto(default,mark,2):

The caller pressed 2 and the call flow will now go to the default context, extension mark, priority 2.

exten => mark,2,Dial(SIP/mark);
In this last step, it would dial the sip user mark. (as defined in sip.conf)

3. Extension

Extension = telephone number? Yes, in general it is true.There are three types of extensions : litteral, predifined and pattern.

The litteral extensions can contain in their name: numbers (0-9), letters A,B,C,D (some hardphones have these letters) or all letters (a-z). Are extension names case sensitive? Yes and no. They are case sensitive when Asterisk have to match a user dialed extension to the extensions that are defined in a context. Extension names are not case sensitive when you try define two extensions (in one context) with same name but different case (you can not do this).

Note: Do not use '_.', because it will match everything even the predefined extensions!!!

Example:

_359ZXXXXXX - This will match all dilaed extensions that start with 359, and are 10 digits long( including 359)
_0XXX. - This will match all dialed extensions that begin with 0 and are minimum 5 digits long (including 0)

So you can see that with help of patterns you can group calls as national, international or local, the only thing you must do is to write the pattern.

4. Other very useful stuff included in extensions.conf

4.1 ignorepad

Another option that can be set is ignorepat. This option instructs drivers
to not cancel dialtone upon receipt specified pattern:Example:

ignorepat => 8 - dialtone will remain after pressing 8

4.2 switch

Switch option permits a server to share his dialplan with
another server (ServerA>ServerB). Note that reciprocal switch
statements are not allowed (ServerA>ServerB and ServerB>ServerA).

switch => IAX2/<username>:[<password>]@<myserver>/<mycontext>

Note that <username> and <password> need to be declared in iax.conf
of the remote server (<myserver>).

4.3 include

You can include all numbers from one context to another context. To do that use:

include => some_context_to_be_included

Except context you can include another configuration file. To do this you have to use '#include':

Karene (ishup3e36nj at yahoo dot com)19 December 2015 15:16:32Wow, wonderful blog<a href="http://cnzzjjf.com"> loayut</a>! How long have you been blogging for? you made blogging look easy. The overall look of your site is magnificent, as well as the content!. Thanks For Your article about About us 1000+ Daily Conversation Exercises DAILY ENGLISH CONVERSATION .

Alexandru (h0dxtx8xvbm at mail dot com)19 December 2015 10:05:54says: I think youve made some actually ientresting points. Not as well many people would really think about this the way you just did. Im definitely impressed that theres so very much about this topic thats been uncovered and you did it so well, with so very much class. Great 1 you, man! Really good stuff here. http://pbjsyrmnjod.com [url=http://lxzozibagg.com]lxzozibagg[/url] [link=http://pxjobw.com]pxjobw[/link]

Samar deep Singh (samarmca at gmail dot com)11 June 2009 12:09:26I configure the asterisk for the vicidial.
I have problem with Quintum.When i do call from anolog quintum for internal office then it is sucessful but when i do call from digital quintum then there is no call from it.
this is the configuration for both quintum.
exten => _X.,1,Wait(1)
exten => _X.,2,Dial(Sip/${EXTEN}@quintumip)
exten => _X.,3,Hangup
Any body know how i configuer the asterisk for calling through quintum.

please help

shamol (shamolia at hotmail dot com)16 August 2008 09:02:51i found a lot of important questions in the http://www.asteriskguru.com/tutorials/extensions_conf.html link . But the ansers are not found here.As, im a new user,If i get the answers my understanding on SIP would be rich.
Thanks

Shamol

saif (gallian866 at hotmail dot com)07 August 2008 15:20:45Connecting two asterisk servers in same network

We have two asterisk servers in same LAN each having one client,now we want to have communication between these clients.we made all required changes in iax.conf.We registered each server in another server's iax.conf file.Both servers when started show that they are reachable but when clients are made to communicate,they cannot do so.So where are we going wrong?can u please suggest?

Akhung (akhung87 at gmail dot com)30 April 2008 04:57:10I develop a softphone, but i need to know IP Address from another client when a dial happen. could i nknow IP Address another client??

alexk (ed at yahoo dot com)03 April 2008 21:34:58Know more about it at http://loadingvault.com
Use the search

ratnesh (iamratnesh at gmail dot com)28 March 2008 08:33:55hi i m new in asterisk. so cd u plz tell me about sip.conf file

We have two asterisk servers in same LAN each having one client,now we want to have communication between these clients.we made all required changes in iax.conf.We registered each server in another server's iax.conf file.Both servers when started show that they are reachable but when clients are made to communicate,they cannot do so.So where are we going wrong?can u please suggest?

vinay (vinay dot parekh1 at wipro dot com)06 December 2007 06:40:22hi all,
i want to make a call from OC to Asterisk,but the problem is,as OC forwards its call with +XXXX (four digit number)but where as asterisk doesn't understand + so plz can any1 help how to truncate this +.

With sip phones I need to dial extensions starting with the hash key (e.g. #200). However, asterisk does not recognize the hash key, even if my extensions.conf includes
exten => '#200' or '_#200' or '_#X.' - lines.

In features.conf, features like blindxfer and others go with '*4', '*5' etc.

With 'sip debug' activated, the dialed number '#200' is recognized as '%23200'.

I'm currently trying with asterisk 1.2.9.1

Does anybody know how to configure asterix such that it recognizes extensions starting with the hash key ?

clifford (reidca at jncb dot com)26 September 2007 16:07:22is it possible to restrict the number of extension to extension calls between two asterisk branch location.

Anand (anand dot poduri at gmail dot com)20 September 2007 13:14:40Hi i want to configure predictive dailer using the asterisk. please anyone can help me out

suraj (suraj at staff dot ownmail dot com)30 August 2007 16:57:36I want to restrict calls from sip user and just want agents user to make calls.Please help me in doing such settings.

scott (sscheffert at glhec dot org)28 August 2007 21:26:03I cannot get the phone to go to voivemail. It rings and never fails to vm.

Greg (greg dot barr at bytecafe dot net)10 May 2007 19:42:15Does Asterisk ignore the timeout on an outbound call? I'm trying to forward calls to a cell phone, but I want it to time out so that Asterisk VM picks up, not cell VM.

bilal (bilal598 at hotmail dot com)16 April 2007 19:08:19hi,
i am new new to asterisk. i need help. someone has its own tutorial in detail plz tell me.
thanks

danny (danny_ros_e at yahoo dot co dot in)20 March 2007 12:57:22hi users, i have a problem with my dial plan, i have configured two companies with same extensions, when i call the second company call is going to the first company user,how can i overcome this problem
pls mail me soon
thanku

Ragnar (spouynt at hotmail dot fr)06 March 2007 18:46:03Hi all,

I installed and configured my Asterisk server, installed an X-Lite client in two machines (for tests), for the configuration i refered to the tutorials and I think that I missed something, because once one machine call the other, the X-Lite says that it's ringing, the Asterisk Console says that it's ringing but X-Lite in the other machine doesn't ring !!
please help me ! it's my first experience with Asterisk and i think it doesn't like me too much :-(

Bill Cheswick (ches at cheswick dot com)25 February 2007 23:14:15Why are the steps in each state definition called "priorities"? An early definition and explanation would help.

mentor (menti_24 at hotmail dot com)22 January 2007 14:53:35hi i have at my office this phone in fact in all offices in facilith we have phones like this but i can configure how to PICKUP my collegs call from my phone when hi is not on office with my static phone i presed *97
buti cant configure this one
i dont know if you understand me what i am saying for example if we are 3 workers in one office an we all have our own phones and if someon calls my colleg and college is not in office i want to answer from my phone i know that is a way to do that plzzzz can you help me how to do that

include => queue2
exten => 2727,1,Dial(SIP/2727)
exten => 2701,1,Dial(SIP/2701)
exten => 9001,1,Dial(SIP/9001)
exten => 9002,1,Dial(SIP/9002)
and through this my aim is to login one agent for both the queues at ones but when i dial 2121 it askes for agentID and Pass but dont login me
kindly help as this is my assignment to complete soon
You can mail me on my gmail ID as follow
swapnshukla@gmail.com
Thanks in advance
Swapnil

I am giving this command to wait the call for 10 sec but its now working please suggest me what to do.
exten => 7115,1,Dial(SIP/${EXTEN}@aricent|10|to)

Regards

Ajit Kumar Singh

kumar (smadhan_kmr at yahoo dot com)09 November 2006 11:57:22I can create the user but i cann`t dial.

manish (manish_alwr at yahoo dot co dot in)07 November 2006 08:21:40Hello friends i am manish i have configur asterisk in my office but i am not able to resive call from pstn as well as my in my voip phom sip is blinking so plese any one can solve this problem mail me on my yahoo id

Carlos G. Candia (vegeta2270 at yahoo dot com)03 November 2006 21:30:03Its greate but i need more information about the code ..... this is more important than what I expected ... please help

Asuncion Py

Rodrigo (rodrigofleitas at yahoo dot com)30 October 2006 20:29:00how I can make automatic calls from my data base?
good tutorial, it helped me, please.
Thanks

angurisudhakar (angurisudhakar20062 at gmail dot com)21 September 2006 05:53:38Dear sir ,
i have one dout,dial palne in sip can u gave brief description.

Randa (randagreen2002 at yahoo dot com)13 September 2006 21:27:08Does anyone know the syntax to drop one digit? For example, any calls coming in with 1 in front would be recognized and drop the 1, but leave the remaining 10 digits. Thanks. I really just dont know how to strip the digit.

Samuel (levysamuel at hotmail dot com)16 August 2006 12:12:57It looks like that the timeout is not working with zap dialing;
when i do:
exten => 1111,1,Dial(ZAP/g1/${EXTEN},5,tT)

the Dial command runs indefinitelly

but when i do:
exten => 1111,1,Dial(SIP/toto,5,tT)

it is working properly with a timeout of 5 seconds.
Lookig the debugging console it looks like zap channel is automatically hanged up when trying to place a call , so the timeout will never be exeeded.With a SIP call the channel will be hanged up when the called party will take the call , so in SIP channels the timeout is effective.
Somebody knows how to use timeout with ZAP channels?
thank you

Samuel (levysamuel at hotmail dot com)16 August 2006 12:08:33It looks like that the timeout is not working with zap dialing;
when i do:
exten => 1111,1,Dial(ZAP/g1/${EXTEN},5,tT)

the Dial command runs indefinitelly

but when i do:
exten => 1111,1,Dial(SIP/toto,5,tT)

it is working properly with a timeout of 5 seconds.
Lookig the debugging console it looks like zap channel is automatically hanged up when trying to place a call , so the timeout will never be exeeded.With a SIP call the channel will be hanged up when the called party will take the call , so in SIP channels the timeout is effective.
Somebody knows how to use timeout with ZAP channels?
thank you

Sandeep Srivastava (sandeep dot ipec at gmail dot com)03 August 2006 19:48:20it is good tutorial .... it help me when i configure asterisk .....

Amy (amy at hotmail dot com)02 August 2006 07:53:40Hey People!!

I had a question regarding the s-extension, here is the code in my incoming context.

What do I need to dial for it to get into this context, i mean answer the call and play the file.

Broadband Voice (broabandvoice at comcast dot net)23 July 2006 14:05:51Disconnecting Customers and putting disco message upon pick up. Anyone tried this before, I want when a certain extension is picked up or when they dial any number they receive the message phone is disconnected please call provider to make payment.

Yudhistira (yudh1z at yahoo dot com)17 July 2006 05:38:41I have a SIP account and i want to make an outgoing call from asteriskm by using this account. Right now i've succed to call another SIP extension on my provider from asterisk, but how to make a call to PSTN that provided by my ISP? And if i have 5 account from my ISP, can i make 5 simultant call from asterisk?

Delian (delian at goldtech dot com)14 July 2006 16:53:31Guys,

I need to use extensions of 10 digit length cause I am using real phone numbers and I want to be able to call those extension from PSTN. My problem is that when I put 10 digit extensions I cannot make a call extension to extension and I don't know why. Has anybody any suggestions?

Any help is appreciated.

Thanks
Delian

Scott (swm5 at hotmail dot com)10 July 2006 05:58:56my extensions.conf is somehow like this

I don´t know why. Could do you help me?
Thanks in advanced
Best regards,
Marcelo Doallo

vikram singh (vikram22712 at rediffmail dot com)25 May 2006 14:38:07very nice tutorial.it helps me alot in asterisk.i want to go through extension.conf.and here everything is clear.and its good place to start for new people like me.
thank u alot.

_ Is a control character and tells * that this is a pattern match.
0 The 1st digit must be a zero.
X Match any digit 0-9. Three X's means there will be three digits.
. Is any digit in any amount.

So, it would match 03524, 02983546234546, but not 13254 or 12983546234546.

Mario Zsilak (peste at peste dot at)14 March 2006 09:17:56_0XXX. - This will match all dialed extensions that begin with 0 and are minimum 5 digits long (including 0)
__________________________________________________________

so what's up?

minimum 5 digits long? but including 0? this is just 1 digit <.<

Robert Poulette (rpoulette at aol dot com)04 March 2006 12:03:54Awsome

jojo (aries_ju at hotmail dot com)12 February 2006 21:36:47can i use java?(some where)

Victoria (viactoria_alexandru at yahoo dot com)07 February 2006 17:11:12According to the doc published by o'reiley, with the new Version 1.2, Asterisk introduces the priority "n" -- next -- and the concept of labels to jump on.

Any details on this? How to declare a label?
Thanks.

Sinisa (sinjanev at yubc dot net)07 February 2006 13:41:41everything is so easy now
My friend Radojko is in nirvana since he has written this tutorial
it so much helped us

maharshi (maharshikiran at yahoo dot com)25 January 2006 06:54:43Hi,
i need to test all the call features for that what i nees to configure in my source code?can u explain a test case with examples

josie (foodygoody at hotmail dot com)29 December 2005 10:10:23could someone please post more and in more detail about setting up external externsions to sip and IAX2 numbers???
I have tried when I put in

I have done this with fwd and freshtell providers all I get is a timed out error?? please help

newren (relianceslee at gmail dot com)23 November 2005 07:07:33i have a problem when configure the extensions.i would like a caller hear some voice when the channel is busy,so how could i do ?

Devinder (devinbhullar at hotmail dot com)17 November 2005 02:06:55Hi I want to make a PSTN call to my office extension number say 7070 is my office phone . How do i configure to allow Asterisks to call extension 7070 in my office. I have a fxo card TDM04B

monte olvera (monte at olveratech dot com)11 November 2005 11:01:12I can receive calls, but cannot make calls to pstn. I have one fxo card. I get error 500.

when you dial a SIP channel, it is the part between the square brackets you need to use in the dial string.

When you want to dial another sip server, its just extension@hostname or extensions@peer (peer being an entry in sip.conf).

Eric De Ron (eric dot de_ron at skynet dot be)18 August 2005 09:47:19I am missing here the link between the extensions and the SIP channels.
- is it the xxx from [xxx] in SIP.conf that is referred to, or the username=yyy inside the [xxx] topic.
- when I want to call outside to another Asterisk SIP server, how is the dialed extension extended (xxx@?????). With the hostname? With the fromdomain parameter???

Bruce (bruce at barton dot net dot nz)05 August 2005 01:17:02A good start but I am looking for the definitive work on Asterisk IVR. Where is the reference that has EVERY command, parameter, setting, etc. I just can't find it....