Archive for March, 2008

Configuring Asterisk for use with EuteliaVoIP (was Skypho)

Posted in Asterisk, EuteliaVoIP, Skypho with tags , , , , , , , on March 31, 2008 by mikeOverIP

EuteliaVoIP is the name of a VoIP service, provided by the Italian carrier Eutelia, which uses the SIP standard protocol and that makes it possible to use it with the Asterisk PBX.
The purpose of this guide is to make and receive phone calls on the traditional land and mobile lines

Index

Why

It is possible to use EuteliaVoIP, as well like every SIP VoIP carrier, with a simple SIP client
Using Asterisk as a PBX became necessary when, for example, one of those requirements must be met:

  • Using more than one phone at the same time
  • Having an answer machine 24/7
  • Having an interactive voice response with menus browsable with the dialpad (IVR)
  • Managing inbound queues
  • Maging automated outbound phone calls, having detailed productivity statistics
  • Bridging different telephony technologies through one PBX, for examples using a traditional analog line together with an ISDN one
  • Having an high availability telephone system, with backup lines and load balancing policies
  • Encrypting automatically and trasparently the communications
  • Record the conversations, incoming and outgoing, and store them in mp3
  • Having the need, in general, of a feature than a traditional PBX is not designed to accomplish

Getting started

An EuteliaVoIP account will be necessary, together with a geographic telephone number (to receive incoming calls), and some prepaid credit (to make outgoing phone calls to the land and mobile lines).
Having Asterisk to work with EuteliaVoIP needs the editing of two configuration files:

  • /etc/asterisk/sip.conf
  • /etc/asterisk/extensions.conf

Only few lines will be added to those files, if they have been already customized from the ones provided by Asterisk, merging them is possible. But this guide is based on the default ones.
It’s possible to reinstall the default example files by running, in the base folder containing the Asterisk source code, the following:
make samples
note that old customized files will be renamed as .old
so for example /etc/asterisk/sip.conf will become /etc/asterisk/sip.conf.old

Description of the sip.conf file

The file /etc/asterisk/sip.conf has everything that concern the use of the SIP protocol.
Being Asterisk a PBX, his role is central in the flow of a phone call, to understand this, here is an explanation of the steps of a phone call made through Asterisk, from a SIP client to a landline number, via EuteliaVoIP:

  • The SIP client tells Asterisk to initiate a call to a landline number, for example 0039611122XXX
  • Asterisk tells EuteliaVoIP to call that number
  • EuteliaVoIP calls that number on the landline, the telephone rings and this signal (of the telephone which rings), is notified to
    Asterisk, which in turn notifies the SIP client: now the caller hears that the called telephone is ringing
  • When the called party answers, Asterisk will send to the SIP client his voice, and viceversa the voice of the SIP client user to the called number

This is to explain that the /etc/asterisk/sip.conf file must have both the details of the SIP client side and the EuteliaVoIP side

First changes to the sip.conf file

  • As the superuser root open the file /etc/asterisk/sip.conf with your favourite text editor
  • Goto line 26 and under the line [general] add those indication, to let the EuteliaVoIP server know that we can receive phone calls:
    register => 069028XXXX:password@voip.eutelia.it:5060/069028XXXX
    where password and 069028XXXX are the secret password and the geographic telephone number given by EuteliaVoIP
  • Then add the indications to make Asterisk aware of it’s external IP address, which is possible to know using one of the services created for this purpose, for example: this one or this one
    insert it like this:
    externip=195.110.1xx.xxx
  • Then add the indication to make Asterisk aware of it’s internal network, which is the same where also are the other clients, which you may retrieve with the command:
    ifconfig
    having for example a result like this:
    eth0 Link encap:Ethernet HWaddr 00:0D:C4:53:2D:24
              inet addr:10.1.1.2 Bcast:10.1.1.255 Mask:255.255.255.0
              inet6 addr: fc41::41c:d4aa:ab41:1d52/64 Scope:Link
              UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
              RX packets:26362155 errors:0 dropped:0 overruns:0 frame:0
              TX packets:26970975 errors:0 dropped:0 overruns:0 carrier:0
              collisions:0 txqueuelen:1000
              RX bytes:4057032333 (3.7 GiB) TX bytes:3026352230 (2.8 GiB)
              Interrupt:17 Base address:0×7000

    note that the IP address of the eth0 network interface of the pc is 10.1.1.2 ( inet addr: ) while it’s netmaks is 255.255.255.0 ( Mask: ).
    Having the IP address of the pc, we can know it’s network by changing the last number after the last dot with 0.
    So the network of the IP address 10.1.1.2 is 10.1.1.0
    Or for example the network of the IP address 192.168.0.219 is 192.168.0.0
    In our configuration we will then write:
    localnet=10.1.1.0/255.255.255.0
  • Now it’s possible to check if our account registered successfully.
    For this to happen we should make Asterisk aware of those changes: rebooting the pc, restarting Asterisk or with a command given at the Asterisk administration console interface prompt.
    Writing, as the superuser root, the command:
    asterisk -r
    we should enter in the Asterisk console administration interface and with the command:
    sip reload
    we are telling Asterisk to read again all the files concerning the SIP protocol.
    We can now check the correct registration with the EuteliaVoIP server with the command:
    sip show registry
    you should read something like:
    Host                           Username     Refresh     State         Reg.Time
    voip.eutelia.it:5060    069028XXXX     285      Registered     Mon, 31 Mar 2008 12:48:21

    where the column State: Registered shows a successful registration

Adding a SIP client to Asterisk

The SIP client is the software, or the hardware, which can make and receive phone calls.
For example an IP SIP phone like one of those
or a SIP softphone, which is a software phone, that you install on your pc and use it with microphone and headphones, like one of those.
In this guide we will be using the softphone X-Lite from CounterPath, but before configuring the softphone, Asterisk should be made aware of it’s existence:

  • Open as the superuser root the file /etc/asterisk/sip.conf with your favourite text editor
  • At the end of the file, paste:
    [1]
    type=friend
    username=1
    secret=12345
    host=dynamic
    insecure=port,invite
    context=myphones

    doing so we created an extention for the upcoming SIP client, giving it the name 1, the password 12345 and the context myphones (which we will discuss later)
  • Save and close the file sip.conf, login to the Asterisk command line interface and write:
    sip reload
    to make Asterisk reload the file sip.conf

Configuration of the softphone X-Lite

The version of X-Lite used when writing this guide was the 2.0, release 1105d.
Note that the pc on which will be installed X-Lite can’t be the same on where is also installed Asterisk, because Asterisk itself is a SIP client: a conflict on udp port number 5060 will occur.
When the X-Lite SIP client will register with Asterisk, a message will appear on the Asterisk console; having a window opened on that console could be useful.

Ok let’s begin, we will now download, install and configure the softphone X-Lite for using it with Asterisk:

  • Download X-Lite for your platform, from here
  • Install and run X-Lite
  • In X-Lite, click on the menu icon, near the right of the “CLEAR” button
  • Click on “System Settings” and then on “Network” and fill the field as following:
    Auto Detect IP: Yes
    Listen on IP: <the ip address of the pc where X-Lite is running>
    Use X-NAT to Choose SIP/RTP Ports: Never
    Listen SIP Port: 5060
    Listen RTP Port: 8000
    Nat Firewall IP: <empty>
    Out Bound SIP Proxy: <empty>
    Force Firewall Type: Open IP
    Primary STUN Server: <empty>
    Secondary STUN Server: <empty>
    Primary DNS Server: <empty>
    Secondary DNS Server: <empty>
    Provider DNS Server: <empty>
    click on “BACK” to return at the “System Settings” menu
  • Click on “SIP Proxy”
    Click on “[Default]” and fill the fields as following:
    Enabled: Yes
    Display Name: 1
    Username: 1
    Authorization User: 1
    Password: 12345
    Domain/Realm: 10.1.1.2 <the ip address of the pc with Asterisk>
    SIP Proxy: 10.1.1.2 <the ip address of the pc with Asterisk>
    Out Bound Proxy: 10.1.1.2 <the ip address of the pc with Asterisk>
    Use Outbound Proxy: Default
    Send Internal IP: Default
    Register: Default
    Voicemail SIP URL: <empty>
    Forward SIP URL: <empty>
    Use Voicemail: Forward to Voicemail
    Direct Dial IP: No
    Dial Prefix: <empty>
    Provider Website (if applicable): <empty>
    Update Settings (if applicable): <empty>
    click on “BACK” to return at the “System Settings” menu, on the Asterisk console a message like the following should appear:
    — Registered SIP ‘1′ at 10.1.1.2 port 5060 expires 1800
    and writing the command (on the Asterisk console):
    sip show peers
    the peers SIP list will be printed

Configuration of the EuteliaVoIP channel

Other than registering Asterisk on the EuteliaVoIP server, a SIP channel must be created in order transmit and receive the voice.
Asterisk will be seen from the EuteliaVoIP server as a SIP client, with all it’s options: network and audio codecs

  • Open as the superuser root the file /etc/asterisk/sip.conf with your favourite text editor
  • At the end of the file, paste:
    [EuteliaVoIP]
    type=friend
    secret=password
    srvlookup=yes
    realm=voip.eutelia.it
    qualify=no
    insecure=port,invite
    username=069028XXX
    host=voip.eutelia.it
    context=EuteliaVoIP-incoming
    fromuser=069028XXX
    fromdomain=voip.eutelia.it
    nat=yes
    canreinvite=no
    disallow=all
    allow=gsm
    allow=ulaw

Programming the lines

The power of Asterisk could be resumed within two specialities: it’s outstanding ability to interconnect different technologies (traditional analog line, ISDN, E1, T1, SS7, VoIP, etc.) and the ability to be programmed.
Asterisk is programmed by the use of commands, functions, macros and variables, which are wrote in the /etc/asterisk/extensions.conf file, which contains the so called dialplan.
To make and receive phone calls, two contexts must be defined:

  • As the superuser root open the file /etc/asterisk/extensions.conf with your favourite text editor
  • At the end of the file, paste:
    [myphones]
    exten => _0.,1,Dial(SIP/${EXTEN:1}@EuteliaVoIP,60)
    exten => _0.,2,Hangup

    [EuteliaVoIP-incoming]
    exten => _X.,1,Dial(SIP/1,60)
    exten => _X.,2,Hangup

    by writing that, we will have that with the first context, Asterisk routes to the EuteliaVoIP server every phone call starting with 0.
    For example, to call the number 3491122XXX you should digit, in X-Lite, 03491122XXX
    With the second context Asterisk will route every incoming phone call to the SIP extention 1 (the X-Lite SIP client)

    • Note that the names of the context are the same used in the sip.conf file
    • The pattern matching expression _0. matches the phone calls starting with 0
    • The incrementing numbers of every directive (row) in the context, defines the execution order
    • Dial it’s a command that makes a new connection with a channel, more info here
    • ${EXTEN:1} is a channel variable which means “the called number without the first number”, so the SIP channel EuteliaVoIP will call the number without the initial 0
    • Hangup sends the “Hangup” signal
  • To apply the changes of the extensions.conf file, in the Asterisk console, write:
    dialplan reload

Example files

Here you will find the final version of the files used in this guide: sip.conf and extensions.conf

Italian Flag

This guide is also available in Italian


AddThis social bookmarking image button
Creative Commons License