free tracking

Jun 22, 2013

Making Your First Asterisk Call On a Single Machine


Using virtualization, we can try executing a basic Asterisk dialplan and make a SIP call between two Windows machines.



Requirements

1. Fully setup Asterisk call manager on your Linux Machine with configuration all set to default
2. Softphone applications (3CX) on Windows 7 host and Windows XP guest
3. Enabled Microsoft Loopback Adapter on Windows 7 host
4. Knowledge on basic networking (LAN connectivity)



Setup LAN Connectivity


All three machines must be on the same subnet. This is the IP configuration I used in this scenario:

Windows 7 host [Microsft Loopback Adapter]
IP Address: 172.30.100.13
Subnet mask: 255.255.255.0

Windows XP guest
IP address: 172.30.100.14
Subnet mask: 255.255.255.0

Ubuntu guest
IP address: 172.30.100.20
Subnet mask: 255.255.255.0


Now we need to test our virtualized LAN connectivity. All machines must be able to ping each other. This is possible using the Microsoft Loopack Adapter on our host machine.


Setup Asterisk

This is the default script for our asterisk.conf
[directories](!)
astetcdir => /etc/asterisk
astmoddir => /usr/lib/asterisk/modules
astvarlibdir => /var/lib/asterisk
astdbdir => /var/lib/asterisk
astkeydir => /var/lib/asterisk
astdatadir => /var/lib/asterisk
astagidir => /var/lib/asterisk/agi-bin
astspooldir => /var/spool/asterisk
astrundir => /var/run/asterisk
astlogdir => /var/log/asterisk

[options]
verbose = 3
;debug = 3
;alwaysfork = yes        ; Same as -F at startup.
;nofork = yes            ; Same as -f at startup.
;quiet = yes            ; Same as -q at startup.
;timestamp = yes        ; Same as -T at startup.
;execincludes = yes        ; Support #exec in config files.
;console = yes            ; Run as console (same as -c at startup).
;highpriority = yes        ; Run realtime priority (same as -p at
                ; startup).
;initcrypto = yes        ; Initialize crypto keys (same as -i at
                ; startup).
;nocolor = yes            ; Disable console colors.
;dontwarn = yes            ; Disable some warnings.
;dumpcore = yes            ; Dump core on crash (same as -g at startup).
;languageprefix = yes        ; Use the new sound prefix path syntax.
;internal_timing = yes
;systemname = my_system_name    ; Prefix uniqueid with a system name for
                ; Global uniqueness issues.
;autosystemname = yes        ; Automatically set systemname to hostname,
                ; uses 'localhost' on failure, or systemname if
                ; set.
;maxcalls = 10            ; Maximum amount of calls allowed.
;maxload = 0.9            ; Asterisk stops accepting new calls if the
                ; load average exceed this limit.
;maxfiles = 1000        ; Maximum amount of openfiles.
;minmemfree = 1            ; In MBs, Asterisk stops accepting new calls if
                ; the amount of free memory falls below this
                ; watermark.
;cache_record_files = yes    ; Cache recorded sound files to another
                ; directory during recording.
;record_cache_dir = /tmp    ; Specify cache directory (used in conjunction
                ; with cache_record_files).
;transmit_silence = yes        ; Transmit silence while a channel is in a
                ; waiting state, a recording only state, or
                ; when DTMF is being generated.  Note that the
                ; silence internally is generated in raw signed
                ; linear format. This means that it must be
                ; transcoded into the native format of the
                ; channel before it can be sent to the device.
                ; It is for this reason that this is optional,
                ; as it may result in requiring a temporary
                ; codec translation path for a channel that may
                ; not otherwise require one.
;transcode_via_sln = yes    ; Build transcode paths via SLINEAR, instead of
                ; directly.
runuser = asteriskpbx        ; The user to run as.
rungroup = asteriskpbx        ; The group to run as.
;lightbackground = yes        ; If your terminal is set for a light-colored
                ; background.
;forceblackbackground = yes     ; Force the background of the terminal to be 
                                ; black, in order for terminal colors to show
                                ; up properly.
;defaultlanguage = en           ; Default language
documentation_language = en_US    ; Set the language you want documentation
                ; displayed in. Value is in the same format as
                ; locale names.
;hideconnect = yes        ; Hide messages displayed when a remote console
                ; connects and disconnects.
;lockconfdir = no        ; Protect the directory containing the
                ; configuration files (/etc/asterisk) with a
                ; lock.

; Changing the following lines may compromise your security.
;[files]
;astctlpermissions = 0660
;astctlowner = root
;astctlgroup = apache
;astctl = asterisk.ctl

[compat]
pbx_realtime=1.6
res_agi=1.6
app_set=1.6

In sip.conf, we set the extensions of the two calling parties to '10013' and '10014' and secret to 'asterisk'. Take note of the context ‘LocalSets’ which we will use next in our dialplan.

sip.conf
[office-phone](!)
type=friend
context=LocalSets
host=dynamic
nat=yes
secret=asterisk
dtmfmode=auto
disallow=all
allow=ulaw
allow=alaw

[10013](office-phone)

[10014](office-phone)



This basic dialplan simply tells Asterisk how to handle calls to and from our machines.

extensions.conf
[LocalSets]

exten => 10013,1,Dial(SIP/10013)

exten => 10014,1,Dial(SIP/10014)


The Asterisk CLI
asteriskpbx@Ubuntu:~$ asterisk -r
Asterisk SVN-branch-1.8-r380210, Copyright (C) 1999 - 2012 Digium, Inc. and others.
Created by Mark Spencer 
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.
=========================================================================
Running as user 'asteriskpbx'
Running under group 'asteriskpbx'
Connected to Asterisk SVN-branch-1.8-r380210 currently running on Ubuntu (pid = 1896)
Verbosity is at least 3
Ubuntu*CLI>

Enter the following commands:
sip reload
dialplan reload


3CX Phone

On Windows 7 host



On Windows XP guest



Note that the password here is 'asterisk' which is the secret we configured in sip.conf. The IP address of the PBX server is '172.30.100.20'

If this setup is successful, you will be able to see this output when you run the command 'sip show users' on Asterisk CLI. This means that our phones have successfully registered in Asterisk.




You can now try your first call by dialing '10014' on Windows 7 host and our phone on Windows XP guest will ring.



This will be the output in Asterisk CLI during the call.



0 comments:

Post a Comment

About Me

aspiring computer and network engineer, programmer, with fascination in webdesign and development

Connect with me

Twitter  GooglePlus  Facebook  LinkedIn  Blogger

Tweet

Featured Post