How to create an Asterisk Dialplan Context on Oracle Linux 9.3
- 00:47 cat /etc/os-release
- 00:59 systemctl status asterisk.service
- 01:14 asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvv
- 01:24 pjsip show endpoints
- 01:44 exit
- 01:52 vim /etc/asterisk/extensions.conf
- 02:42 asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvv
- 02:52 dialplan reload
- 03:47 exit
- 03:57 cd /var/lib/asterisk/sounds/en
- 04:13 ls
- 04:42 vim /etc/asterisk/extensions.conf
- 05:10 asterisk -rvvvvvvvvvvvvvvvv
- 05:17 dialplan reload
To Create An Asterisk Dialplan Context On Oracle Linux9.3
Introduction:
The Dialplan is truly the heart of any Asterisk system, as it defines how Asterisk handles inbound and outbound calls. In a nutshell, it consists of a list of instructions or steps that Asterisk will follow. Unlike traditional phone systems, Asterisk’s Dialplan is fully customizable. To successfully set up your own Asterisk system, you will need to understand the Dialplan.
Procedure:
Step 1: Check the System OS version by using the below command.
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2 : Check the status of the Asterisk by using the below command
[root@linuxhelp ~]# systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Mon 2024-02-19 04:02:05 IST; 3 days ago
Docs: man:systemd-sysv-generator(8)
Process: 1001 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
Main PID: 1062
Tasks: 37 (limit: 21739)
Memory: 64.9M
CPU: 22.697s
CGroup: /system.slice/asterisk.service
├─1056 /bin/sh /usr/sbin/safe_asterisk
└─5831 /usr/sbin/asterisk -f -vvvg -c
Feb 19 04:02:05 linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Feb 19 04:02:05 linuxhelp asterisk[1001]: Starting asterisk:
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) after start: Operation not permitted
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Supervising process 1062 which is not our child. We'll most likely not notice when it exits.
Feb 19 04:02:05 linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Step 3 : Login to the Asterisk CLI mode by using the below command
[root@linuxhelp ~]# asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 5831)
-- Remote UNIX connection
linuxhelp*CLI>
Step 4 : Show the endpoints by using the below command
linuxhelp*CLI> pjsip show endpoints
Endpoint: <Endpoint/CID.....................................> <State.....> <Channels.>
I/OAuth: <AuthId/UserName...........................................................>
Aor: <Aor............................................> <MaxContact>
Contact: <Aor/ContactUri..........................> <Hash....> <Status> <RTT(ms)..>
Transport: <TransportId........> <Type> <cos> <tos> <BindAddress..................>
Identify: <Identify/Endpoint.........................................................>
Match: <criteria.........................>
Channel: <ChannelId......................................> <State.....> <Time.....>
Exten: <DialedExten...........> CLCID: <ConnectedLineCID.......>
==========================================================================================
Endpoint: 167/167 Unavailable 0 of inf
InAuth: 167/167
Aor: 167 1
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Endpoint: 168/168 Unavailable 0 of inf
InAuth: 168/168
Aor: 168 1
Transport: tcp_transport tcp 3 96 0.0.0.0:5060
Objects found: 2
Step 5 : Exit from the Asterisk CLI mode by using the below command
linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups
Step 6: Edit the extensions.conf file to modify the dialplan by using the below command.
[root@linuxhelp ~]# vim /etc/asterisk/extensions.conf
Add the following Lines
[internal]
exten => _XXX,1,NoOp(Call started for ${EXTEN})
exten => _XXX,n,Dial(PJSIP/${EXTEN},10)
exten => _XXX,n,Playback()
exten => _XXX,n,Hangup()
;exten => 167,1,NoOp(Call started for ${EXTEN})
;exten => 167,2,Dial(PJSIP/167,10)
;exten => 167,3,Hangup()
;exten => 168,1,Dial(PJSIP/168)
Step 7: Again login to the Asterisk CLI mode by using the below command.
[root@linuxhelp ~]# asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 7289)
linuxhelp*CLI>
Step 8 : Reload the Dialplan by using the below command
linuxhelp*CLI> dialplan reload
Dialplan reloaded.
-- Time to scan old dialplan and merge leftovers back into the new: 0.000004 sec
-- Time to restore hints and swap in new dialplan: 0.000006 sec
-- Time to delete the old dialplan: 0.000003 sec
-- Total time merge_contexts_delete: 0.000013 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Result
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 7289)
-- Executing [168@internal:1] NoOp("PJSIP/167-00000000", "Call started for 168") in new stack
-- Executing [168@internal:2] Dial("PJSIP/167-00000000", "PJSIP/168,10") in new stack
-- Called PJSIP/168
-- PJSIP/168-00000001 is ringing
-- Nobody picked up in 10000 ms
-- Executing [168@internal:3] Playback("PJSIP/167-00000000", "") in new stack
[Feb 23 00:34:48] WARNING[7522][C-00000001]: app_playback.c:464 playback_exec: Playback requires an argument (filename)
== Spawn extension (internal, 168, 3) exited non-zero on 'PJSIP/167-00000000'
Step 9: Exit from the Asterisk CLI mode by using the below command
linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups
Step 10: Move to the directory to find the sounds for playback by using the below command
[root@linuxhelp ~]# cd /var/lib/asterisk/sounds/en
[root@linuxhelp en]# ls
1-for-am-2-for-pm.alaw easterly.siren7 north-dakota.wav step-in-stream.g729
1-for-am-2-for-pm.g722 easterly.sln16 northerly.alaw step-in-stream.gsm
1-for-am-2-for-pm.g729 easterly.ulaw northerly.g722 step-in-stream.siren14
1-for-am-2-for-pm.gsm easterly.wav northerly.g729 step-in-stream.siren7
1-for-am-2-for-pm.siren14 eastern.alaw northerly.gsm step-in-stream.sln16
1-for-am-2-for-pm.siren7 eastern.g722 northerly.siren14 step-in-stream.ulaw
1-for-am-2-for-pm.sln16 eastern.g729 northerly.siren7 step-in-stream.wav
1-for-am-2-for-pm.ulaw eastern.gsm northerly.sln16 sterling.alaw
1-for-am-2-for-pm.wav eastern.siren14 northerly.ulaw sterling.g722
1-yes-2-no.alaw eastern.siren7 northerly.wav sterling.g729
1-yes-2-no.g722 eastern.sln16 north.g722 sterling.gsm
1-yes-2-no.g729 eastern.ulaw north.g729 sterling.siren14
1-yes-2-no.gsm eastern.wav north.gsm sterling.siren7
1-yes-2-no.siren14 east.g722 north.siren14 sterling.sln16
1-yes-2-no.siren7 east.g729 north.siren7 sterling.ulaw
1-yes-2-no.sln16 east.gsm north.sln16 sterling.wav
1-yes-2-no.ulaw east.siren14 north.ulaw still_on_phone.alaw
1-yes-2-no.wav east.siren7 north.wav still_on_phone.g722
abandon-all-hope.alaw east.sln16 not-auth-pstn.alaw still_on_phone.g729
abandon-all-hope.g722 east.ulaw not-auth-pstn.g722 still_on_phone.gsm
abandon-all-hope.g729 east.wav not-auth-pstn.g729 still_on_phone.siren14
abandon-all-hope.gsm echo-test.alaw not-auth-pstn.gsm still_on_phone.siren7
abandon-all-hope.siren14 echo-test.g722 not-auth-pstn.siren14 still_on_phone.sln16
abandon-all-hope.siren7 echo-test.g729 not-auth-pstn.siren7 still_on_phone.ulaw
abandon-all-hope.sln16 echo-test.gsm not-auth-pstn.sln16 still_on_phone.wav
abandon-all-hope.ulaw echo-test.siren14 not-auth-pstn.ulaw store-accounting.alaw
abandon-all-hope.wav echo-test.siren7 not-auth-pstn.wav store-accounting.g722
abandons.alaw echo-test.sln16 not-enough-credit.alaw store-accounting.g729
abandons.g722 echo-test.ulaw not-enough-credit.g722 store-accounting.gsm
abandons.g729 echo-test.wav not-enough-credit.g729 store-accounting.siren14
abandons.gsm ed.alaw not-enough-credit.gsm store-accounting.siren7
abandons.siren14 ed.g722 not-enough-credit.siren14 store-accounting.sln16
abandons.siren7 ed.g729 not-enough-credit.siren7 store-accounting.ulaw
abandons.sln16 ed.gsm not-enough-credit.sln16 store-accounting.wav
abandons.ulaw ed.siren14 not-enough-credit.ulaw storm.alaw
abandons.wav ed.siren7 not-enough-credit.wav storm.g722
academic-support.alaw ed.sln16 nothing-recorded.alaw storm.g729
academic-support.g722 ed.ulaw nothing-recorded.g722 storm.gsm
academic-support.g729 ed.wav nothing-recorded.g729 storm.siren14
academic-support.gsm eighteenth.alaw nothing-recorded.gsm storm.siren7
academic-support.siren14 eighteenth.g722 nothing-recorded.siren14 storm.sln16
academic-support.siren7 eighteenth.g729 nothing-recorded.siren7 storm.ulaw
academic-support.sln16 eighteenth.gsm nothing-recorded.sln16 storm.wav
academic-support.ulaw eighteenth.siren14 nothing-recorded.ulaw sun.alaw
academic-support.wav eighteenth.siren7 nothing-recorded.wav sun.g722
access-code.alaw eighteenth.sln16 not_me.alaw sun.g729
access-code.g722 eighteenth.ulaw not_me.g722 sun.gsm
access-code.g729 eighteenth.wav not_me.g729 sunny.alaw
access-code.gsm eighth.alaw not_me.gsm sunny.g722
access-code.siren14 eighth.g722 not_me.siren14 sunny.g729
Step 11: Add any of the above sound to the extensions.conf file to add the playback sound to the channel by using the below command
[root@linuxhelp en]# vim /etc/asterisk/extensions.conf
[internal]
exten => _XXX,1,NoOp(Call started for ${EXTEN})
exten => _XXX,n,Dial(PJSIP/${EXTEN},10)
exten => _XXX,n,Playback(your-account)
exten => _XXX,n,Hangup()
;exten => 167,1,NoOp(Call started for ${EXTEN})
;exten => 167,2,Dial(PJSIP/167,10)
;exten => 167,3,Hangup()
;exten => 168,1,Dial(PJSIP/168)
Step 12 : Login to the Asterisk CLI mode and reload the Dialplan by using the below command
[root@linuxhelp en]# asterisk -rvvvvvvvvvvvvvvvv
Asterisk 20.5.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.5.0 currently running on linuxhelp (pid = 7289)
linuxhelp*CLI> dialplan reload
Dialplan reloaded.
-- Time to scan old dialplan and merge leftovers back into the new: 0.000005 sec
-- Time to restore hints and swap in new dialplan: 0.000006 sec
-- Time to delete the old dialplan: 0.000003 sec
-- Total time merge_contexts_delete: 0.000014 sec
-- pbx_config successfully loaded 1 contexts (enable debug for details).
Result
Executing [167@internal:1] NoOp("PJSIP/168-00000006", "Call started for 167") in new stack
-- Executing [167@internal:2] Dial("PJSIP/168-00000006", "PJSIP/167,10") in new stack
-- Called PJSIP/167
-- PJSIP/167-00000007 is ringing
-- Nobody picked up in 10000 ms
-- Executing [167@internal:3] Playback("PJSIP/168-00000006", "your-account") in new stack
> 0x7ffa800391e0 -- Strict RTP learning after remote address set to: 192.168.6.102:4028
-- <PJSIP/168-00000006> Playing 'your-account.ulaw' (language 'en')
> 0x7ffa800391e0 -- Strict RTP switching to RTP target address 192.168.6.102:4028 as source
-- Executing [167@internal:4] Hangup("PJSIP/168-00000006", "") in new stack
== Spawn extension (internal, 167, 4) exited non-zero on 'PJSIP/168-00000006'
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to create Asterisk Dialplan context on Oracle Linux 9.3. Your feedback is much welcome.
Comments ( 0 )
No comments available