VoIP Cookbook: EXTENSIONS.CONF Configuration
The dial plan or routing table of a softswitch is normally stored in /etc/asterisk/extensions.conf. In extensions.conf we can configure what Asterisk needs to do as it receives a call on a certain extension. The simplest example of dial plan is:
exten => _20XX,1,Dial(SIP/${EXTEN},20,rt) exten => _20XX,2,HangUp
which means that if there is someone who calls extension 20XX, then the first step carried out by the syntax is to have DIAL of the extension use SIP technology, wait for 20 seconds and if there is no response, carry out time-out (rt). The second step is to hang up. Of course you need to do a small configuration of the command so it will fit your circumstance in how you use your SIP server.
Some commands considered dangerous but often sought by user/admin are as follows:
exten => _0711.,1,Dial(SIP/${EXTEN:4}@2031,20.rt)
which means that there is someone who calls 0711. The dot “.” implies that any number after 0711 is ignored. DIAL uses SIP technology to connect to 2031. Also note carefully the code {EXTEN:4} has to be read “omit the first 4 digits of the dialed number.” For example: 07115551234 becomes 5551234.
If we use PABX between ATA and PSTN, the command used is as the following:
exten => _021X.,1,Dial(SIP/9${EXTEN:3}@2031,20.rt)
The syntax above implies that there is someone who calls 021X. Notice that the dot “.” placed after X implies that any number placed after X is ignored. DIAL uses SIP technology to connect to 2031. Also note carefully the code 9{EXTEN:3} has to be read “omit the first 3 digits of the dialed number” and “add the prefix 9 in front of the number.” For example: 0215551234 becomes 95551234
This means that if the number 2031 originates from an Analog Telephone Adapter (ATA) such as the SPA3000 located in the Jakarta and is connected to a PABX in Jakarta, anyone in such a VoIP network will be able to call Jakarta without having to pay long distance or international call. What they need to pay is just the local rate for calling the intended number in Jakarta city.
The same way can be developed for calling mobile phone in Indonesia by connecting the ATA we use to PSTN or any Fixed Wireless Terminal (FWT) device. The command used is as follows
exten => _08X.,1,Dial(SIP/${EXTEN}@2031,20.rt)
Of course, an office that is connected to a public VoIP network will not open its access so that only certain users can call any mobile number or Telkom, and thus we usually do not use 021X. code, nor 08X. But we will enter each of the numbers allowed to be called through VoIP. For example:
exten => _0811567854,1,Dial(SIP/${EXTEN}@2031,20.rt) exten => _0216575675,1,Dial(SIP/${EXTEN}@2031,20.rt) exten => _0216755675,1,Dial(SIP/${EXTEN}@2031,20.rt)
This means that only number 0811567854, 0216575675 and 0216755675 can be contacted via VoIP numbers. Other than these numbers cannot be contacted.
To adopt the phone number format similar to Telco, e.g., +62 XXX or other numbers we may include ENUMLOOKUP command, for example,
exten => _00.,1,Set(enumresult=${ENUMLOOKUP(+${EXTEN:2},,,,e164.id)}) exten => _00.,n,Dial(SIP/${enumresult}) exten => _+.,1,Set(enumresult=${ENUMLOOKUP(${EXTEN},,,,e164.id)}) exten => _+.,n,Dial(SIP/${enumresult})