ITC-2300 VoIP Lab Sample extensions.conf File

From ITCwiki
Revision as of 02:20, 20 November 2019 by BenFranske (talk | contribs)
Jump to navigation Jump to search

Below you will find some sample snippets from the extensions.conf file. These are not complete configurations and will also need to be modified for your Pod.

Basic SCCP Phone Extensions in the Default Context

[default]
exten => 2901,1,Dial(SCCP/sally-line1,120) ; Modify with correct extension number and line name
exten => 2902,1,Dial(SCCP/john-line1,120) ; Modify with correct extension number and line name

Placing Calls to the PSTN over T1/ISDN

It's a good idea to separate different types of outgoing calls into different contexts in your dialplan so that you can restrict which extensions are able to place which types of calls. For example, you probably do not want to allow calls anywhere except to the operator and 911 from a phone in the elevator, only internal extensions and local calls from the lobby, and only allow executives to place international calls. In order to do this you would want to divide up your outgoing patterns into different contexts and then include those contexts into various other contexts which are assigned to various phones/lines.

For example you might have some internal extensions assigned to the [lobby] context, others to the [elevator] context, others to [general_staff] and still others to [executive]. Note these assignments are done in channel driver file (e.g. PJSIP, SCCP, etc.) and NOT in the dialplan! Tee dialplan only shows what extensions you can actually DIAL once you are in a specific context.

Let's start just by allowing a test call to directory assistance if someone dials 9-411 in the default context since we haven't done any dividing of extensions into different contexts just yet.

[default]
exten => 9411,1,Dial(PJSIP/411@ISDNrouter,120)

To allow calls that we don't know the exact number for requires that we do some pattern matching like this:

[default]
exten => _9NXXXXXX,1,Dial(PJSIP/510${EXTEN:1}@ISDNrouter,120)

The X's in the extension number will match digits 0-9 and the N digits 2-9. All local numbers are 7 digits and can't start with a 0 or 1 so this should match all local calls. We then send the extension on to our ISDNrouter SIP gateway but we need to change the number we're sending a little bit. First, our ISDN provider requires 10 digit dialing even for local numbers so we've told Asterisk to always add a 510 area code onto the front of 7 digit numbers. Secondly, we don't want to include the 9 to get an outside line in our ISDN call so we use ${EXTEN:1} instead of ${EXTEN} to remove the first digit from whatever number was dialed.

You can create similar rules for other types of calls like 10-digit local, long distance, international, toll-free, 1-900, etc.

But what if we want to follow best practice of dividing up all the different types of calls? In this case we need to make several changes to our dialplan structure and move everything out of the default context:

[internal_extensions]
; In this context you will want to include numbers for each internal line someone could call
exten => 2901,1,Dial(SCCP/sally-line1,120)
exten => 2902,1,Dial(SCCP/john-line1,120)

[PSTN_emergency]
; In this context you want to include the rules used to dial out to emergency numbers
exten => 9911,1,Dial(PJSIP/911@ISDNrouter,120)
exten => 911,1,Dial(PJSIP/911@ISDNrouter,120)

[PSTN_directoryassist]
; In this context you want to include the rules used to dial out to directory assistance
exten => 9411,1,Dial(PJSIP/411@ISDNrouter,120)

[PSTN_local]
; In this context you want to include the rules used to dial out to local numbers
exten => _9NXXXXXX,1,Dial(PJSIP/510${EXTEN:1}@ISDNrouter,120)
exten => _9510NXXXXXX,1,Dial(PJSIP/${EXTEN:1}@ISDNrouter,120)

You can create similar contexts for patterns that match long distance, international, 1-900, and toll-free numbers. Of course once you have done this you still need to determine which phones can call which of these numbers. To do this you need to assign each phone line to a context in it's channel driver configuration file (like PJSIP or SCCP). You can then include the contexts you created above into these contexts. Assuming you have placed different phones/lines into some of these contexts your dialplan might include something like this:

[elevator]
; The elevator should only be able to call emergency services
include => PSTN_emergency

[lobby]
; The lobby phone can call any internal extension, or local PSTN numbers
include => PSTN_emergency
include => internal_extensions
include => PSTN_local

[general_staff]
; Most people can call internal extensions, directory assistance, local, and long distance numbers
include => PSTN_emergency
include => internal_extensions
include => PSTN_local
include => PSTN_directoryassist
include => PSTN_long_distance

[executives]
; Executives can call the same things as the general staff plus internationally
include => PSTN_emergency
include => internal_extensions
include => PSTN_local
include => PSTN_directoryassist
include => PSTN_long_distance
include => PSTN_international

Fixing Caller ID

First, let's get some terminology right. When you place a call over a T1/ISDN line you can send a number the call is being placed from, but not a name, this is called ANI (Automatic Number Identification) data. Caller ID is actually a service where the recipient of a call can look this number up against a directory maintained by the phone company and match it to a name which they can then display. So, to change the name that is displayed by people with Caller ID you need to get the name set correctly in the phone company's directory for each of your DID numbers. But you CAN control what ANI data you send with each call by telling your ISDN/T1 gateway what the source phone number is.

In Asterisk you can change the source phone number is after a particular extension or pattern is dialed like this:

exten => _9NXXXXXX,1,Set(CALLERID(num)=5105552900)
exten => _9NXXXXXX,2,Dial(PJSIP/510${EXTEN:1}@ISDNrouter,120)

Note that we have added an additional priority before we actually dial out to the PSTN where we run the Set(CALLERID(num)=...) command which changes the Caller ID number which our ISDN/T1 gateway will use to tell the phone company what number the call is coming from using ANI. In this case we've decided to always set our calling number to 5105552900 but you might want to set it to 510555XXXX where XXXX is the internal extension number (which we set as the Caller ID value in the channel driver) since we've setup extensions to receive calls on all these DIDs too:

exten => _9NXXXXXX,1,Set(CALLERID(num)=510555${CALLERID(num)})
exten => _9NXXXXXX,2,Dial(PJSIP/510${EXTEN:1}@ISDNrouter,120)

Reloading After Configuration Changes

If you make changes to the extensions.conf file and need to get Asterisk to re-load the dialplan you can run the dialplan reload command from the Asterisk CLI to re-read the file.

Additional Resources

  • Coming soon