The file is located in the /etc/asterisk/ directory.
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.
In general a dialplan looks like this:
[general]
--> some settings go here
[globals]
--> definition of some global variables go here
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.
[mainmenu]
exten => s,1,Answer
exten => s,n,Background(thanks) ; "Thanks for calling press 1 for sales, 2 for support, ..."
exten => s,n,WaitExten
exten => 1,1,Goto(submenu,s,1)
exten => 2,1,Hangup
[submenu]
exten => s,1,Ringing ; Make them comfortable with 2 seconds of ringback
exten => s,n,Wait,2
exten => s,n,Background(submenuopts) ; "Thanks for calling the sales ;department. Press 1 for steve, 2 for..."
exten => s,n,WaitExten
exten => 1,1,Goto(default,steve,1)
exten => 2,1,Goto(default,mark,2)
Lets have a closer look at what the lines above do exactly.
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).
There are several predefined extension names:
- i - Invalid
- s - Start
- h - Hangup
- t - Timeout
- T - AbsoluteTimeout
- o - Operator
Example:
some example
If extension name starts with '_', it is consider as pattern.
For the extension that use pattern, some characters have special meaning:
- X - any digit from 0-9
- Z - any digit from 1-9
- N - any digit from 2-9
- [12679] - any digit in the brakets (in the example: 1,2,6,7,9)
- . - (dot) wildcard, matches everything remaining
( _1234. - matches anything strating with 1234 excluding 1234 itself).
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).
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':
#include "some_file_to_be_included.conf"
User Comments
Samar deep Singh (samarmca at gmail dot com) 11 June 2009 12:09:26 I 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:51 i 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:45 Connecting 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:10 I 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:58 Know more about it at http://loadingvault.com
Use the search
ratnesh (iamratnesh at gmail dot com) 28 March 2008 08:33:55 hi i m new in asterisk. so cd u plz tell me about sip.conf file
tumhara baap (tumhara_baap at yahoo dot com) 24 March 2008 20:27:05 kutti kay bacho fazul may apna dimagh kharch kartay ho or oron ko bee takleef daytay ho bohat he ziaaaaaaaaaaaaadaaaaaaaaaa harammmmmmmmmmi ho tum log
Babu (babu dot s at alaap dot biz) 08 March 2008 11:36:31 Hi,
I am new to Asterisk, i Want to configure Asterisk PBX for two different network to communicate.
Can any body Email me Sample Configuration to do it and also procedure to test.
thanks in Advances.
Babu.S
faheem (faheemahmed007 at gmail dot com) 22 February 2008 14:31:17 hi
how do we configure IVR in asterisk....
faheem (faheemahmed007 at gmail dot com) 22 February 2008 14:31:04 hi
how do we configure IVR in asterisk....
Renuka (xtech dot 07 at gmail dot com) 31 January 2008 13:46:07 Connecting 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?
vinay (vinay dot parekh1 at wipro dot com) 06 December 2007 06:40:22 hi 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 +.
Bert (stein_bert at gmx dot net) 06 October 2007 10:30:42 Hash key problem
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:22 is 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:40 Hi 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:36 I 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:03 I cannot get the phone to go to voivemail. It rings and never fails to vm.
where do I set this. I prefer after 4 rings, (24 seconds)...
rose (ROSEANDJOSHEP at HOTMAIL dot COM) 19 August 2007 16:45:04 QUE NO LEE EL ROXTER
saeed (sabbasi at sinamicro dot com) 19 August 2007 14:27:23 Dear guru,
How can I make changes to the contex in the extensions_additional.conf while it is "overwritten" to previous values each time a form submitted through Asterisk Management portal?
for example, i want to comment a line in extensions_additional.conf but it's uncommented each time i click submit in the AMP,
Please help me,
Thanks in advance,
Saeed
originalguest (matay_kan8 at hotmail dot com) 07 June 2007 15:32:49 1555/88
VruniwkA (vitcen-pchela at mail dot ru) 21 May 2007 08:52:31 äàéòå ðóñèê :( íèõåðà íå ïîÿíÿòíî
Greg (greg dot barr at bytecafe dot net) 10 May 2007 19:42:15 Does 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:19 hi,
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:22 hi 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:03 Hi 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:15 Why 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:35 hi 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
Swapnil (swapnshukla at gmail dot com) 11 December 2006 23:09:58 Hi All
I have created one Agent Login Extention as follows
exten => 2121,1,AgentCallbacklogin(||@queues)
and where my queues Context is as follows
[queues]
include => queue1
exten => 2727,1,Dial(SIP/2727)
exten => 2701,1,Dial(SIP/2701)
exten => 9001,1,Dial(SIP/9001)
exten => 9002,1,Dial(SIP/9002)
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
ajitkumar (kumarajitsingh at gmail dot com) 05 December 2006 07:32:35 Hi all.
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:22 I can create the user but i cann`t dial.
manish (manish_alwr at yahoo dot co dot in) 07 November 2006 08:21:40 Hello 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:03 Its 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:00 how 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:38 Dear 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:08 Does 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:57 It 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:33 It 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:20 it is good tutorial .... it help me when i configure asterisk .....
Amy (amy at hotmail dot com) 02 August 2006 07:53:40 Hey 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:51 Disconnecting 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:41 I 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:31 Guys,
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:56 my extensions.conf is somehow like this
if dial '2' or 's' it works perfect as expected, when dial any other digit, it did not play the 'welcome', know why the 's' extension is not auto started?
Marcelo (mdoallo at buenosaires dot gov dot ar) 08 June 2006 22:54:19 I have this context in the extension.conf file:
[gcba]
exten=> _[2-7]XXX,1,SetCDRUserField(${CENTRAL})
exten=> _[2-7]XXX,2,SetAMAFlags(omit)
exten=> _[2-7]XXX,3,Dial(Zap/34/${EXTEN},30)
exten=> _[2-7]XXX,4,Congestion
The problem appear when a user dial 4343 (for example), the call goto internos context.
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:07 very 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.
jerome (jerome dot charpentier at teleca dot fr) 11 May 2006 15:22:56 I'm configuring an extension.conf to enable overlap mode for channel h323, i saw something like this : exten => _X! Dial(...), someone knows how to use it?
Thanks for help!
HW (nospam-hweaver at frontier-nospam-net dot dot dot net) 02 May 2006 19:55:23 Here you go bruce - a list of all commands
http://www.voip-info.org/wiki/index.php?page=Asterisk+-+documentation+of+application+commands
Nguyen Huy Tuan (nguyenhuytuan at gmail dot com) 26 April 2006 10:23:25 Co ban nao o Viet Nam dang can mua Card Digium, co the tham khao tai:
http://www.vfonex.com
Hoolio (asteriskgurucomments at hamsrc dot com) 06 April 2006 17:34:38 _0XXX.
_ 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:54 Awsome
jojo (aries_ju at hotmail dot com) 12 February 2006 21:36:47 can i use java?(some where)
Victoria (viactoria_alexandru at yahoo dot com) 07 February 2006 17:11:12 According 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:41 everything 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:43 Hi,
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
arunvnair1 at gmail dot com (arunvnair1 at gmail dot com) 10 January 2006 10:24:46 arunvnair1 at gmail dot com
Omar Khaled (omar dot khaled at viragelogic dot com) 05 January 2006 03:55:55 How can I configure to call another sip asterisk server? Can anyone help please.
charles ogwang (cogwang at tech dot mak dot ac dot ug) 04 January 2006 20:34:10 I have enjoyed reading thgis page i did not prevoiusly understand what it means by interactive voice response.
josie (foodygoody at hotmail dot com) 29 December 2005 10:10:23 could 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:33 i 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:55 Hi 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:12 I can receive calls, but cannot make calls to pstn. I have one fxo card. I get error 500.
Charles (not at my dot email dot com) 03 November 2005 01:31:26 RE: Eric's question about extension/SIP relationship.
Contexts in the SIP/IAX config files allow phones to connect to the server. Extensions are the actual phone numbers, which you connect to the SIP/IAX contexts via the Dial command.
IE, if I have the following sip.conf entry:
[charles]
type=friend
user=charles
...
And I want to have the phone number 6789 I'd need the following extension:
exten => 6789, 1, Dial(SIP/charles)
deepak malik (d_malik at rediffmail dot com) 19 October 2005 12:17:04 it is good tutorial .... it help me when i configure asterisk .....
Thomas (baa at bridgeallianceasia dot com) 02 September 2005 11:27:28 I good place to start for newbies like me.
zoa (support at asteriskguru dot com) 18 August 2005 11:05:45 Ah een belgske sie :)
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:19 I 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???
Thanks for the help
kazam (kazam at hrorg dot com) 17 August 2005 22:47:13 crisp, simple and short.
Bruce (bruce at barton dot net dot nz) 05 August 2005 01:17:02 A 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....
Arun (arunvnair1 at gmail dot com) 19 July 2005 12:38:19 very good tutorial. Simple and helpful
Benjamin Rösler (seacabo at gmx dot de) 12 July 2005 13:57:25 good tutorial,