Dial Plan Manipulation

i had configured asterisk with a minimum dial plan, made 10 extentions plz find extentions.conf and sip.con in attachment
i want configure dial plan so that

Extention 2000-2005 can receive and make calls outside and can dial all ten extentions.
Extention 2006-2010 can only receive calls and can dial all ten extentions

thx

#########################################################################################################
vi /etc/asterisk/sip.conf

[general]
port = 5060
bindaddr = 0.0.0.0
context = others

[2000]
type=friend
context=my-phones
secret=1234
host=dynamic

[2001]
type=friend
context=my-phones
secret=1234
host=dynamic

[2002]
type=friend
context=my-phones
secret=1234
host=dynamic

[2003]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2004]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2005]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2006]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2007]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2008]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2009]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2010]
type=friend
contex=my-phones
secret=1234
host=dynamic

#########################################################################################################

vi /etc/asterisk/extensions.conf
[others]
exten => 2000,1,Dial(SIP/2000)
exten => 2001,1,Dial(SIP/2001)
exten => 2002,1,Dial(SIP/2002)
exten => 2003,1,Dial(SIP/2003)
exten => 2004,1,Dial(SIP/2004)
exten => 2005,1,Dial(SIP/2005)
exten => 2006,1,Dial(SIP/2006)
exten => 2007,1,Dial(SIP/2007)
exten => 2008,1,Dial(SIP/2008)
exten => 2009,1,Dial(SIP/2009)
exten => 2010,1,Dial(SIP/2010)
########################################################################################################

plz guide me how to achieve this

You need to read about contexts and includes, that solve your problem, create a context called “all” per example for the extension 2000-2005, other maybe called “only-in” for the 2006-2010. Then in your extension create your rules.

[from-zap]
exten=>s,1,wait(2)
exten=>s,2,background(yourivr)
include=>all /* here you include your 2 contexts for incoming calls can reach all phones*/
include=>only-in

[all]
/your outgoing rule/
include=>alldevices

[only-in]
include=>alldevices

[alldevices]
exten=>_20XX,1,dial(SIP/${EXTEN})
/add more precisely rule or macro/

i had configured sip and extensions.conf like this, but not able 2 get sucess plz tell me where i am doing mistake.

sip.conf

[general]
port = 5060
bindaddr = 0.0.0.0
context = others

[2000]
type=friend
context=others
secret=1234
host=dynamic

[2001]
type=friend
context=others
secret=1234
host=dynamic

[2002]
type=friend
context=others
secret=1234
host=dynamic

[2003]
type=friend
contex=others
secret=1234
host=dynamic

[2004]
type=friend
contex=others
secret=1234

[2005]
type=friend
contex=others
secret=1234
host=dynamic

[2006]
type=friend
contex=others
secret=1234
host=dynamic

[2007]
type=friend
contex=others
secret=1234
host=dynamic

[2008]
type=friend
contex=others
secret=1234
host=dynamic

[2009]
type=friend
contex=others
secret=1234
host=dynamic

[2010]
type=friend
contex=others
secret=1234
host=dynamic

vi /etc/asterisk/extensions.conf

[globals]

LOWEXT=2000
HIEXT=2005

[others]
include => my-phones
include => outbound

[my-phones]
exten => _20XX,1,Dial(SIP/${EXTEN})
exten => _20XX,1,Voicemail(${EXTEN}@others,u)
exten => _20XX,n,Hangup()

exten => 2000,1,Answer()
exten => 2000,n,Dial(SIP/2000)

[outbound]
exten => _NXXXXXX,1,Set(MYCHANEXTEN=${CDR(channel):4:4})
exten => _NXXXXXX,n,gotoIf($["${MYCHANEXTEN}" >= “${LOWEXT}” & “${MYCHANEXTEN}” <= “${HIEXT}”]?ALLOWDIAL:DENYDIAL)

exten => _NXXXXXX,n,(DENYDIAL),hangup()
exten => _NXXXXXX,n,(ALLOWDIAL),Dial(Zap/1-1/${EXTEN})
exten => _NXXXXXX,n,Hangup()

###################################################################################

_NXXXXXX this is for i want to dial a local no 2346651

right now i havent got the success.

sip accounts 2000-2005 should have context=others
sip accounts 2006-2010 should have context=my-phones

hi friend i had done like this but still not got success, i want that exten 2000 to 2005 can make call outside and exten 2006 to 2010 can not make calls.

vi /etc/asterisk/sip.conf

[root@localhost ~]# vi /etc/asterisk/sip.conf
[general]
port = 5060
bindaddr = 0.0.0.0
context = others

[2000]
type=friend
context=my-phones
secret=1234
host=dynamic

[2001]
type=friend
context=my-phones
secret=1234
host=dynamic

[2002]
type=friend
context=my-phones
secret=1234
host=dynamic

[2003]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2004]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2005]
type=friend
contex=myphones
secret=1234
host=dynamic

[2006]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2007]
type=friend
contex=my-phones
secret=1234

[2008]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2009]
type=friend
contex=my-phones
secret=1234
host=dynamic

[2010]
type=friend
contex=my-phones
secret=1234
host=dynamic

###################################################################################

vi /etc/asterisk/extentions.conf
[from-zaptel]
exten => s,1,wait(2)
exten => s,n,dial(sip/2000)
exten => s,n,dial(sip/2001)
exten => s,n,Playback(tt-weasels)

[others]
include => my-phones

[my-phones]
exten => _20XX,1,Dial(SIP/${EXTEN})
exten => _20XX,n,VoiceMail(${EXTEN}@others,u)
exten => _20XX,n,Hangup()

exten => 2001,1,Dial(Zap/1-1/${EXTEN})
exten => 2001,n,Hangup

exten => 2002,1,Dial(Zap/1-1/${EXTEN})
exten => 2002,n,Hangup

exten => 2003,1,Dial(Zap/1-1/${EXTEN})
exten => 2003,n,Hangup

exten => 2004,1,Dial(Zap/1-1/${EXTEN})
exten => 2004,n,Hangup

exten => 2005,1,Dial(Zap/1-1/${EXTEN})
exten => 2005,n,Hangup

###################################################################################
any help n support will be highly appreciated

Is this a school homework? because we already answer for your issue’s. So If you don’t want to change the contexts in your devices (sip.conf), you need to create maybe an AGI script and read the callerdID or username, if the username is over 2005 cant make outgoings calls else they can.

But is easier with context and dialplan rules.

made dial plan plz check where i am wrong

sip.conf

[general]
port = 5060
bindaddr = 0.0.0.0
context = others

[2000]
type=friend
context=outside
secret=1234
host=dynamic

[2001]
type=friend
context=outside
secret=1234
host=dynamic

[2002]
type=friend
context=outside
secret=1234
host=dynamic

[2003]
type=friend
contex=outside
secret=1234
host=dynamic

[2004]
type=friend
contex=outside
secret=1234
host=dynamic

[2005]
type=friend
contex=outside
secret=1234
host=dynamic

[2006]
type=friend
contex=internal
secret=1234
host=dynamic

[2007]
type=friend
contex=internal
secret=1234
host=dynamic

[2008]
type=friend
contex=internal
secret=1234
host=dynamic

[2009]
type=friend
contex=internal
secret=1234
host=dynamic

[2010]
type=friend
contex=internal
secret=1234
host=dynamic

############################################################################################

vi /etc/asterisk/extensions.conf

[from-zaptel]
exten => s,1,wait(2)
exten => s,n,dial(sip/2000)
exten => s,n,dial(sip/2001)
exten => s,n,Playback(tt-weasels)

[others]
include => internal
include => outside

[inside]
exten => _20XX,1,Dial(SIP/${EXTEN})
exten => _20XX,n,VoiceMail(${EXTEN}@others,u)
exten => _20XX,n,Hangup()

[outside]
exten => 2001,1,Dial(Zap/1-1/${EXTEN})
exten => 2001,n,Hangup

exten => 2002,1,Dial(Zap/1-1/${EXTEN})
exten => 2002,n,Hangup

exten => 2003,1,Dial(Zap/1-1/${EXTEN})
exten => 2003,n,Hangup

exten => 2004,1,Dial(Zap/1-1/${EXTEN})
exten => 2004,n,Hangup

exten => 2005,1,Dial(Zap/1-1/${EXTEN})
exten => 2005,n,Hangup

this is the log when i am calling from exten 2000 to outside

Connected to Asterisk 1.4.29 currently running on localhost (pid = 2243)
Verbosity is at least 3
[Feb 13 12:05:47] NOTICE[2482]: chan_sip.c:15124 handle_request_invite: Call from ‘2002’ to extension ‘919369613616’ rejected because extension not found.

Man you are really confused, you need to read more about everything in asterisk such as contexts, dial-patterns, and especial extensions.

So, lets try to explain in a easy way -then please read more for yourself-:

Devices: the devices are softphones(xlite,eyebeam,zoiper etc) and hardphones(ATAs, grandstream, polycom,aastra etc), this need to have a username to register with the server, all devices are in the SIP.CONF

Extensions: The extensions are the rules or dial-patterns to make calls, call can be internal or external, and between two or more servers. To cretae extensions you will use the extension.conf file. There are 3 most used especial extensions:

extension i: wich means invalid, is used for send a message or action when you dial an invalid or non-exits extension.
extension s: wich means start, is used when a incoming call is detected, most used for IVRs etc. If you dont define a DID you maybe want to use the s extension.
extension t: wich mean timeout, is used to send a user a message or action when the timeout is reached.

Channel: The channel is the type of medium wich server uses to generate the call, it can be: SIP, IAX, ZAP/DAHDI, Skype etc. Depending on your channles you need to defined in the Sip.conf, iax.conf or chan_dahdi.conf etc.

Contexts: The contexts are the “label” wich devices belong to and dial rules, the context must be defined in sip.conf, chan_dahdi, iax.conf; in the extensions.conf you create rules for dial in each context for your convenience. You can include context between them using the include command.

So you have 11 devices 2000-2010, you want 2000-2005 can receive call from outside, can make calls to outside and make calls to 11 devices. And you want 2006-2007 devices can only recieve calls from outside and call 11 devices.

You need at least 3 context -you can call your context as you want-:
[outside] to generate external calls
[incoming] to receive external calls
[ext] to call between 11 devices

Devices 2000-2005 belong to outside context
devices 2006-2010 belong to ext context

Now your dial plan maybe look like this:

[incoming]
exten=>s,1,wait(2)
exten=>s,2,background(yourivr) or your command
include=>ext ;here you include all devices for be dialed

[outside]

here you create a match pattern wich means all dialed with 9+every number will be dialed with chan zap/1, the variable EXTEN takes the number that you dialed and remove the first digit from left to right in this case 9, for example if you want to dial this number 7895625; In your phone you enter: 97895625, then zap dial without the 9

exten=>_9XX.,1,dial(zap/1/${EXTEN:1})
exten=>_9XX.,2,hangup()
include=>ext ;here you include all devices to be dialed

[ext]
here you create the rule for dial all 11 devices, you can create individual rules or one rule or even a macro, I use a one rule:
wich means every dialed starts with 20 dial via SIP

exten=>_20[0-1]X,1,dial(SIP/${EXTEN})

so you can only dial extensions with 200 or 201 and the las digit can be 0 to 9, so you can call 2000-2010 devices.

Now in the “incoming” context I include the “ext” context so every incoming call from outside can reach 11 devices
In the “outside” context I include “ext” so the devices belong to “outside” can dial outside and dial all devices
In the “ext” context you create the rule for dial every 11 devices, and the devices belong to “ext” only can receive calls an dial 11 devices.

Hope this helps to understand…

PD:Sorry my english

thx for ur support, this is how i did it.

#############################################################################################

vi /etc/asterisk/sip.conf

[general]
port = 5060
bindaddr = 0.0.0.0
context = others

[2000]
type=friend
context=outside
secret=1234
host=dynamic

[2001]
type=friend
context=outside
secret=1234
host=dynamic

[2002]
type=friend
context=outside
secret=1234
host=dynamic

[2003]
type=friend
context=outside
secret=1234
host=dynamic

[2004]
type=friend
context=outside
secret=1234
host=dynamic

[2005]
type=friend
context=outside
secret=1234
host=dynamic

[2006]
type=friend
contex=internal
secret=1234
host=dynamic

[2007]
type=friend
contex=internal
secret=1234
host=dynamic

[2008]
type=friend
contex=internal
secret=1234
host=dynamic

[2009]
type=friend
contex=internal
secret=1234
host=dynamic

[2010]
type=friend
contex=internal
secret=1234
host=dynamic

##############################################################################################

vi /etc/asterisk/extensions.conf

[from-zaptel]
exten => s,1,wait(2)
exten => s,n,dial(sip/2000)
exten => s,n,dial(sip/2001)
exten => s,n,Playback(tt-weasels)

[internal]
exten => _20XX,1,Dial(SIP/${EXTEN})
exten => _20XX,n,VoiceMail(${EXTEN}@others,u)
exten => _20XX,n,Hangup()

[outside]
exten => _X.,1,Dial(Zap/1-1/${EXTEN})
exten => _X.,n,Hangup