Free phone booth

Business PBX Solutions
Provider Solution Details
Bicom VoIP Become an ITSP Now!
  • Become a serious competitor in VoIP Immediately
  • FULL Consultancy, Installation, Training & Support
  • Sell Hosted IP PBXs, Biz Lines, Call Centre
  • Turnkey Provisioning at your data center
Details
3CX Software PBX for Windows
  • Windows Software Solution
  • Easy to Install and Manage
  • Auto Configures Phones & Trunks
  • Android, iOS, Windows & Mac clients
Details
You can see the original document in spanish in this link.
You can also join our development group in the free social network n-1.cc.


Introduction

Image

This tutorial we explain how to build up from scratch a low cost telephone booth for making free calls to landline phones to more than 40 countries using Asterisk and SIP provider. It explains the hardware and software technical requirements for setting one up.


All what we use is easy to find, excepting the ATA adpator, althoug for using Asterisk we don't need it, it just requires it if it wants to be connected to analogic telephones. We can also configure it with an IP telephone, or connecting with a softone like Ekiga. Asterisk PBX are the ones supporting more protocols and channels: from landline lines to SIP clients/servers, H323.b, IAX2, ATA voip adaptors, FXS/FXO boards and there is also a project for announcing it as a BTS (GSM antenas for mobile phones)


For installing the cabins that we have setted up we have used:



Other usable hardware

Modems PCI that can work as x100p. The ones with chipsets:

  • Motorola 62802
  • Intel 537PG
  • Intel 537PU
  • Ambient MD3200

Routers that can be hacked as ATA.

(Don't have FXO, just FXS for plugg telphones in)
  • Blue router from Tele2.
  • SMC7908A-ISP (ya.com's grey router). It is highly recommended deactivate the firmware/conf automatic updates. Use the modified HTML from this web link, link
  • Arcadyan 7518PW (ya.com's white). It is the same as the SMC7908A-ISP, but comes with a newer firmware that requires to modify directly the backup file. Learn more here
  • Speedtouch 780 (Sapo.pt ADSL). Just configure the ISP accounts that you want from the web interface.


What is Asterisk?

Asterisk is a free software(GPL) aplication that gives you the PBX features. Like every PBX, you can connect with a determined telephones for making calls between them and also for connecting to a VoIP provider or to a primary or basic RDSI.

We will install it in Debian, a free GNU/Linux distribution. For starting we will install all its updates:

  1. apt-get update
  2. apt-get dist-upgrade

We could see more information about the Asterisk installation on Debian in the following link.


Through the repositories:

The easiest and quicker way to install it is with thge following command:

  1. sudo aptitude install asterisk


With the source code:

Now we we'll install the dependencies, along with the necessary tools for compiling and the kernel sources.

  1. apt-get -y install build-essential libncurses5-dev libcurl3-dev
libvorbis-dev libspeex-dev unixodbc unixodbc-dev libiksemel-dev
linux-headers-`uname -r


We go to the sources directory.

  1. cd /usr/src


We download and uncompress the Asterisk sources along with the needed Zaptel module:

  1. wget http://downloads.digium.com/pub/asterisk/asterisk-1.45.1.tar.gz
  2. wget http://downloads.digium.com/pub/zaptel/zaptel-1.45.1.tar.gz
  3. tar xvzf asterisk-1.4.5.1.tar.gz
  4. tar xvzf zaptel-1.4.5.1.tar


We go to the zaptel directory:

  1. cd zaptel-1.4.


Configure, compile and install the module.

  1. ./configure && make && make inst


Load it with the modprobe command.

  1. modprobe ztdumm


We can test if it has loaded correctly:

  1. lsmod | grep ztdumm


If we see that works we have to add it to the system's home in the etc/modules file.

  1. echo “ztdummy” >> /etc/module


We compile Asterisk. We go to its directory and launch the same commands as before:

  1. cd /usr/src/asterisk-1.4.5.1
  2. ./configure && make && make install


It's recommended install the examples for having something where to work on:

  1. make samples
  2. make config


Sources:




Starting / Stopping Asterisk

For starting Asterisk as daemon.

  1. service asterisk start


For stopping it:

  1. service asterisk stop


For restarting

  1. service asterisk restart


If we want to start it for a period of time and not always, we should strat it with this command.

  1. /usr/sbin/asterisk -vvvvc

With this we will be starting the application and enter into the terminal, [*CLI>]. You can see how to play with it in the terminal and logs section link.


If we started it as a daemon, for connecting to the terminal we should do it with the same command with the -r option instead of -c:

  1. /usr/sbin/asterisk -vvvvr

If we want it to start everytime we start the computer we should modify the following file:

  1. nano /etc/default/asterisk
RUNASTERISK=yes


How do we configure this?

Once we have all installed we could have a look at the configuration files we have installed in the previous steps.

  1. less /etc/asterisk/sip.conf
  2. less /etc/asterisk/extension.conf

These files are the ones we are going to see more in the tutorial. In sip.conf we configure the clients, peers or friends (in asterisk jargon) that we'll have and in extensions.conf our DialPlan. This is our call plan: what will it do when it'll get a call from that extension, or what it will do when a user will try to call to another one.

The other files that are in the /etc/asterisk are for all other functionalities that it offers us. This is the main advantatge from Asterisk versus the other PBX systems. From the beginning and just by modifying a single line at the files we could have awesome features like the conferences' room (meetme.conf), answerphone (voicemail.conf) and conectivity with different VoIP protocol's types (sip.conf) an IAX2 (iax.conf).

We are going to start now, so we will make and a security copy of the files we already have.

  1. mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.old
  2. mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.old



SIP.CONF

In this file we are configuring all diferent users, clients and peers. Here is where our configure could differ more. All Asteris's configuration files start with [general], with global options and after each label will serve for avery one of its clients. These could be from SIP software clients (Softones like Ekiga or Twinkle), an analogic phone, an ATA adaptor or a SIP telephony provider. If we have a PCI FXS or FXO card we will the configuration in zapata.conf.

In our case the hardware we are using is an ATA Linksys SPA302 adaptor configured in the [phonebooth1] label. We are also connecting it to a SIP telphone provider called VoipBuster, in the [VoipBuster] label. In this example the [phonebooth2] label stands as an example of a connection made with another SIP telephone provider.

[general]
context=default
useragent=
disallow=all
allow=gsm
allow=alaw
allow=ulaw
language=es
srvlookup=yes
tos_sip = cs3
tos_audio = ef
tos_video = af41
allowguest = yes

register => yourvoipbuster.comuser:PASSWORD@sip1.VoipBuster.com:5060

[phonebooth1]
type=friend
host=dynamic
username=phonebooth1
secret=PASSWORD
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes
[VoipBuster]
type=peer
host=sip1.VoipBuster.com
username=yourvoipbuster.comuser
fromuser=yourvoipbuster.comuser
secret=PASSWORD
context=VoipBuster
insecure=port,invite
qualify=yes
canreinvite=no  

[phonebooth2]
type=friend
host=dynamic
username=phonebooth2
secret=PASSWORD
callerid="Phone booth placed in Y"
context=phonebooths
mailbox=3000@default
qualify=yes


Step by step:

[general]
context=default
useragent=
disallow=all
allow=gsm
allow=alaw
allow=ulaw
language=es
srvlookup=yes
tos_sip = cs3
tos_audio = ef
tos_video = af41
allowguest = yes  

register => yourvoipbuster.comuser:PASSWORD@sip1.VoipBuster.com:5060


Here we are telling the context where the label is (we will see this again in extensions.conf), also which codec types we are allowing (gsm, alaw, ulaw) and the language (spanish, later we'll install the sounds)

The register line has the same data as the [VoipBuster] label. It is needed in some providers.

The ATA adaptor

Image


[phonebooth1]
type=friend
host=ATAIP
username=phonebooth1
secret=PASSWORD
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes

Here we will need to put the adaptor's IP or host name, along with name and password. Another important issue is the context, in this case [voipbuster]

[voipbuster]
type=peer
host=sip1.VoipBuster.com
username=yourvoipbuster.comuser
fromuser=yourvoipbuster.comuser
secret=PASSWORD
context=voipbuster
insecure=port,invite
qualify=yes
canreinvite=no


In this label the important is the host, which is an URL that our provider gives us when we register. We choose VoipBuster for allowing us to make free calls during 120 days paying 10 euros to more than 50 countries


What is the problem with VoipBuster?

They are changing countries' listings without notice, so it's posible that they are taking us some credit.



Configuring another user.

The only different thing from before is the host, which is dynamic, so it can have any IP.

[phonebooth2]
type=friend
host=dynamic
username=phonebooth2
secret=PASSWORD
callerid="Phone booth placed in Y"
context=phonebooths
qualify=yes



EXTENSIONS.CONF


[general]
static=yes
writeprotect=yes

[globals]
phonebooth1=SIP/phonebooth1
VoipBuster=SIP/voipbuster
phonebooth2=SIP/phonebooth2

[default]

[phonebooth1]
include => default
include => nationals
include => echo
include => monkeys 

[phonebooth2]
include => default
include => nationals
include => echo
include => monkeys  

[nationals]  
exten => _9ZXXXXXXX,1,Dial(${VoipBuster}/0034${EXTEN},60,r)
exten => _9ZXXXXXXX,n,Hangup
[eco]
exten => 600,1,Playback(demo-echotest)
exten => 600,n,echo
exten => 600,n,Playback(demo-echodone)
exten => 600,n,Hangup
[monkeys]
exten => 666,1,Answer()
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeysintro)
exten => 666,n,Playback(tt-somethingwrong)
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeys)
exten => 666,n,Hangup 



Step by step:

[general]
static=yes
writeprotect=yes 

[globals]
phonebooth1=SIP/phonebooth1
VoipBuster=SIP/VoipBuster
phonebooth2=SIP/phonebooth2

The original context, where we'll put the options for the extensions.conf file. We protect it and put the variables in globals. It has to be written considering the created users in the sip.conf file. We create 3 variables: one for the ATA adaptor (user phonebooth1 and context phonebooths in the sip.conf, variable phonebooth1), another one for voipbuster and last one for the user that is going to connect by softphones.

[default] 
[phonebooth1]
include => default
include => nationals
include => echo
include => monkeys  

[phonebooth2]
include => default
include => nationals
include => echo
include => monkeys 


These are the contexts from the users that are making the calls, phonebooth1 and phonebooth2. The ISP provider, obviously, will not make calls, we will route them to it instead. The "include" just means that we are adding these contexts (default, nacionales, echo and monkeys).
 
[nationals]
exten => _9ZXXXXXXX,1,Dial(${VoipBuster}/0034${EXTEN},60,tr)
exten => _9ZXXXXXXX,n,Hangup

This is the sintaxis that we'll use for defining what to do when we make a phonecall. For example, here we are defining that when dialing a telephone starting with a 9 and the following number will be bigger than 0 (Z) and the following 7 numbers would be bigger or equal to 0 (XXXXXXX), first (1) dial to the number that we have previously configured as belonging to VoipBuster the number it's been dialed ($EXTEN) adding the countries' international code, (Spain has the 0034). We also tell it to call during 60 seconds and request it to allow the trasfer and not listening the dialling tone (tr). After we tell it that when it will finish with this, to hang up. All of this in just 2 lines!!

Through the DialPlan we could do. i.e.:

[echo]
exten => 600,1,Playback(demo-ecotest)
exten => 600,n,echo
exten => 600,n,Playback(demo-ecodone)
exten => 600,n,Hangup

Here we are teling that for the [echo] context, is the 600 extension. First it will play (Playback) a sound that says that is going to do a echo test with demo-echotest, that is in /var/lib/asterisk/sounds/ or wherever else we have installed it.
Important: the audio format is not needed, Asterisk will choose which is best in every case. After it calls the program that does the echo test, and tells to play to another sound if it decided that the echo test is over. At last stage, it hangs up. About the sintaxis, we could have written this like:

[echo]
exten => 600,1,Playback(demo-ecotest)
exten => 600,2,eco
exten => 600,3,Playback(demo-ecodone)
exten => 600,4,Hangup  


But in this case when we'll want to change it we should renumber it all, that is why is prefered to use the "n" for calling the following action:

[monkeys]
exten => 666,1,Answer()
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeysintro)
exten => 666,n,Playback(tt-somethingwrong)
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeys)
exten => 666,n,Hangup

Here we tell it to attend, to wait for 2 seconds, to play some sounds (monkeys introduction and another), to wait for 2 seconds, to play another sounds (monkeys!!) and hang up.

The only remaining context in this configuration is [internationals]. Because is a so long configuration that so many people could see we decided to liberate it in the voip-info.org link wiki. For seeing the updated listing for making calls to landlines, click here. link.

All this would agreggate in the extensions.conf and also as "includes" in the user to we want to enable the international calls.

You can read a further configuration of extensions.conf here



Softphone client configuration

EKIGA

Image

It comes with Ubuntu. You can find it in Aplications -> Internet -> Softphone Ekiga,

We will create an account with what we have put in sip.conf, along with the server IP. If we want to connect from internet the needed ports we should open and put the public IP or the domain that we have associated to this.

Account name: phonebooth1 
Protocol: SIP
Registrant: 192.168.10.1
User: phonebooth1
Password: PASSWORD



TWINKLE

Image

Install

  1. sudo aptitude install twinkle

We will open it and will create a new profile using the sip.conf file configuration. The Domain should be our server's IP.

Our configuration will be like this:

Your name: phonebooth1
User name: phonebooth1
Domain: 192.168.10.1
Authentication name: phonebooth1
Password: PASSWORD

After we should see in the Twikle log:

phonebooth, registration succeeded (expires = 3600 seconds)


Configuration of the ATA adaptor.

Image

For configurating the SPA-3102, with a line of exit for making calls and another one of in/out PSTN, that means an a normal telephone line, we should make:

In the navigator we type the IP of the adaptor.

It tells us "spa user". We should login with user and password. User "user" and without password. The page we enter is a information page about the actual configuration.

Go to the admisitrator section, in "Admin login". We type again the user and the password ("admin user"). This time we login like user admin and without password:

From here we can configure:

En Voice -> System we can change the access password (User Password:). Clicking in "Advanced" we can change the admin password too.(Admin Password:)
En Router -> Wan Setup we put an static ip adress inside of our net range. Here we can configurate like router ("PPPoE Settings") too
En Voice -> Line 1 configurating our line for making calls. We should put like the minimum next parameters:
Line enable: yes
SIP Port: 5060
Proxy: ASTERISKIP
Register: yes
Display name: phonebooth1
Configure adaptor ATA 3102 - 1

Password: PASSWORD
Auth ID: phonebooth1
User ID: phonebooth1
Use Auth ID: phonebooth1
Preferred Codec: G711u
Use Pref codec only: no


We can configurate Asterisk in the next way.

[phonebooth1]
type=friend
host=ATAadaptorIP
username=phonebooth1
secret=PASSWORD  n
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes
En Voice -> PSTN Line configurating our PSTN line for make and recieve calls.
SIP Port: 5061

Configure adaptator ATA 3102 - 2

Proxy: ASTERISKIP
Register: yes
Display Name: pstn
Password: PASSWORD
Auth ID: pstn
User ID: pstn
Use Auth ID: no
Preferred Codec: G711a
Use Pref Codec Only: no

We can configure Asterisk in the next way.

[pstn-spa3k]
type=peer
auth=md5
host=ATAadaptorIP
port=5061
secret=PASSWORD 
username=pstn
fromuser=pstn
dtmfmode=rfc2833
context=incoming-pstn
insecure=very




Terminal and logs

Soon we will see in the terminal that Asterisk is completly intuitive and an ally to solve problems. For conecting to the terminal depends on how we begin Asterisk.

First we check if the command is running.

  1. ps auxf | grep asterisk


In case of we can't see, we should connect entering the next command:

  1. /usr/sbin/asterisk -vvvvc


If we begin like daemon, for connecting to the terminal we should enter with the same command, but with the option -r not -c:

  1. /usr/sbin/asterisk -vvvvr


If we have some doubts about this point, you can read the section "Iniciate/Stop Asterisk"

Once inside the terminal you should see the next (Note: CLI means Command Line Interface)
  • CLI>

When an user connects or makes a call we will see that there. I.e. When the user phonebooth1 connects through Twinkle appears the next:

Registered IP 'phonebooth1' at 192.168.10.135 port 5060 expires 3600
Saved useragent "Twinkle/1.2" for peer phonebooth1
[Apr  5 20:01:20] NOTICE[8449]: chan_sip.c:12669 handle_response_peerpoke: Peer 'phonebooth1' is now Reachable. (25ms / 2000ms)


And when he disconnects:

Saved useragent 
Unregistered SIP 'phonebooth1'


When you connected with Ekiga:

Registered SIP 'phonebooth1' at 192.168.10.135 port 5061 expires 3600
Saved useragent "Ekiga/2.0.12" for peer phonebooth1
[Apr  5 20:10:27] NOTICE[[8449]: chan_sip.c:12669 handle_response_peerpoke: Peer 'phonebooth1' is now Reachable. (32ms / 2000ms) 


When you make a call to 666 [monkeys], we see the DialPlan executing in real time:

Executing [666@phonebooth1:1] Answer("SIP/phonebooth1-089832b8", "") in new stack
Executing [666@phonebooth1:2] Wait("SIP/phonebooth1-089832b8", "2") in new stack
Executing [666@phonebooths:3] Playback("SIP/phonebooth1-089832b8", "tt-monkeysintro") in new stack
<SIP/phonebooth1-089832b8> Playing 'tt-monkeysintro' (language 'es')
Executing [666@phonebooths:4] Playback("SIP/phonebooth2-089832b8", "tt-somethingwrong") in new stack
<SIP/phonebooth2-089832b8> Playing 'tt-somethingwrong' (language 'es')
Executing [666@phonebooths:5] Wait("SIP/phonebooth1-089832b8", "2") in new stack
== Spawn extension (phonebooth1, 666, 5) exited non-zero on 'SIP/phonebooth1-089832b8'  

(That doesn't end with all because the user hang on before)

We can see the state of our provider

*CLI> [Apr  5 20:18:36] NOTICE[[28025]: chan_sip.c:12669 handle_response_peerpoke: Peer 'voipbuster' is now Reachable. (90ms / 2000ms) 

Appart of showing us the information in real time, we can ask information and change configuration. For learning how to move inside it our great ally is the Tab key. With that we complete and see what options the command can give us, for example, if we write "sip show" and push the Tab key.

  • CLI> sip show

channel        channels       domains        history        inuse          objects        
peer             peers            registry          settings       subscriptions  user           
users           

That's intuitive and we can reach the diferent dates:

*CLI>  sip show users 
Username                       Secret           Accountcode      Def.Context            ACL  NAT       
phonebooth2                  PASSWORD                            phonebooths           No   RFC3581   
phonebooth1                  PASSWORD                            phonebooths           No   RFC3581  


*CLI> sip show registry 
Host                            Username          Refresh State                Reg.Time                 
sip1.voipbuster.com:5060        phonebooth1       105 Registered           Sun, 05 Apr 2009 20:18:36 
 

*CLI> sip show peers
Name/username                             Host                       Dyn Nat    ACL Port          Status               
phonebooth2/phonebooth2            192.168.10.135            D          5061             OK (4 ms)            
voipbuster/yourvoipbuster.comuser  194.221.62.198                        5060             OK (90 ms)           
phonebooth1/phonebooth1            (Unspecified)                 D                0             UNKNOWN              
3 sip peers [Monitored: 2 online, 1 offline Unmonitored: 0 online, 0 offline]


We can test the DialPlan, for example with the command "console dial 666"

*CLI> console dial 666
No such extension '666' in context 'default'

In this case this doesn't work beacuse we don't have an extension configurated in the default context, but for make tests is recommended type in there (is enough to put it there as "include"). The good thing is that if the server have speakers and microphone we can test it harmlessly.



Further and beyond

Image


Something reamining to see that is very funny to configure is the voicemail.conf and the meetme.conf for i.e. put the sound in spanish.

You can see more information about in the VOIP-info.org wiki. It has detailed information about lots of configuration files and providers, and connect diferent devices and aplications to Asterisk.

If you a are more interested in the learning further about this free IP telephones world the best you can read is the Asterisk book: The Future of Telephony.

You can also join our development group in the free social network n-1.cc

Enjoy
Image

You can see the original document in spanish in this link.
You can also join our development group in the free social network n-1.cc.


Introduction

Image

This tutorial we explain how to build up from scratch a low cost telephone booth for making free calls to landline phones to more than 40 countries using Asterisk and SIP provider. It explains the hardware and software technical requirements for setting one up.


All what we use is easy to find, excepting the ATA adpator, althoug for using Asterisk we don't need it, it just requires it if it wants to be connected to analogic telephones. We can also configure it with an IP telephone, or connecting with a softone like Ekiga. Asterisk PBX are the ones supporting more protocols and channels: from landline lines to SIP clients/servers, H323.b, IAX2, ATA voip adaptors, FXS/FXO boards and there is also a project for announcing it as a BTS (GSM antenas for mobile phones)


For installing the cabins that we have setted up we have used:



Other usable hardware

Modems PCI that can work as x100p. The ones with chipsets:

  • Motorola 62802
  • Intel 537PG
  • Intel 537PU
  • Ambient MD3200

Routers that can be hacked as ATA.

(Don't have FXO, just FXS for plugg telphones in)
  • Blue router from Tele2.
  • SMC7908A-ISP (ya.com's grey router). It is highly recommended deactivate the firmware/conf automatic updates. Use the modified HTML from this web link, link
  • Arcadyan 7518PW (ya.com's white). It is the same as the SMC7908A-ISP, but comes with a newer firmware that requires to modify directly the backup file. Learn more here
  • Speedtouch 780 (Sapo.pt ADSL). Just configure the ISP accounts that you want from the web interface.


What is Asterisk?

Asterisk is a free software(GPL) aplication that gives you the PBX features. Like every PBX, you can connect with a determined telephones for making calls between them and also for connecting to a VoIP provider or to a primary or basic RDSI.

We will install it in Debian, a free GNU/Linux distribution. For starting we will install all its updates:

  1. apt-get update
  2. apt-get dist-upgrade

We could see more information about the Asterisk installation on Debian in the following link.


Through the repositories:

The easiest and quicker way to install it is with thge following command:

  1. sudo aptitude install asterisk


With the source code:

Now we we'll install the dependencies, along with the necessary tools for compiling and the kernel sources.

  1. apt-get -y install build-essential libncurses5-dev libcurl3-dev
libvorbis-dev libspeex-dev unixodbc unixodbc-dev libiksemel-dev
linux-headers-`uname -r


We go to the sources directory.

  1. cd /usr/src


We download and uncompress the Asterisk sources along with the needed Zaptel module:

  1. wget http://downloads.digium.com/pub/asterisk/asterisk-1.45.1.tar.gz
  2. wget http://downloads.digium.com/pub/zaptel/zaptel-1.45.1.tar.gz
  3. tar xvzf asterisk-1.4.5.1.tar.gz
  4. tar xvzf zaptel-1.4.5.1.tar


We go to the zaptel directory:

  1. cd zaptel-1.4.


Configure, compile and install the module.

  1. ./configure && make && make inst


Load it with the modprobe command.

  1. modprobe ztdumm


We can test if it has loaded correctly:

  1. lsmod | grep ztdumm


If we see that works we have to add it to the system's home in the etc/modules file.

  1. echo “ztdummy” >> /etc/module


We compile Asterisk. We go to its directory and launch the same commands as before:

  1. cd /usr/src/asterisk-1.4.5.1
  2. ./configure && make && make install


It's recommended install the examples for having something where to work on:

  1. make samples
  2. make config


Sources:




Starting / Stopping Asterisk

For starting Asterisk as daemon.

  1. service asterisk start


For stopping it:

  1. service asterisk stop


For restarting

  1. service asterisk restart


If we want to start it for a period of time and not always, we should strat it with this command.

  1. /usr/sbin/asterisk -vvvvc

With this we will be starting the application and enter into the terminal, [*CLI>]. You can see how to play with it in the terminal and logs section link.


If we started it as a daemon, for connecting to the terminal we should do it with the same command with the -r option instead of -c:

  1. /usr/sbin/asterisk -vvvvr

If we want it to start everytime we start the computer we should modify the following file:

  1. nano /etc/default/asterisk
RUNASTERISK=yes


How do we configure this?

Once we have all installed we could have a look at the configuration files we have installed in the previous steps.

  1. less /etc/asterisk/sip.conf
  2. less /etc/asterisk/extension.conf

These files are the ones we are going to see more in the tutorial. In sip.conf we configure the clients, peers or friends (in asterisk jargon) that we'll have and in extensions.conf our DialPlan. This is our call plan: what will it do when it'll get a call from that extension, or what it will do when a user will try to call to another one.

The other files that are in the /etc/asterisk are for all other functionalities that it offers us. This is the main advantatge from Asterisk versus the other PBX systems. From the beginning and just by modifying a single line at the files we could have awesome features like the conferences' room (meetme.conf), answerphone (voicemail.conf) and conectivity with different VoIP protocol's types (sip.conf) an IAX2 (iax.conf).

We are going to start now, so we will make and a security copy of the files we already have.

  1. mv /etc/asterisk/sip.conf /etc/asterisk/sip.conf.old
  2. mv /etc/asterisk/extensions.conf /etc/asterisk/extensions.conf.old



SIP.CONF

In this file we are configuring all diferent users, clients and peers. Here is where our configure could differ more. All Asteris's configuration files start with [general], with global options and after each label will serve for avery one of its clients. These could be from SIP software clients (Softones like Ekiga or Twinkle), an analogic phone, an ATA adaptor or a SIP telephony provider. If we have a PCI FXS or FXO card we will the configuration in zapata.conf.

In our case the hardware we are using is an ATA Linksys SPA302 adaptor configured in the [phonebooth1] label. We are also connecting it to a SIP telphone provider called VoipBuster, in the [VoipBuster] label. In this example the [phonebooth2] label stands as an example of a connection made with another SIP telephone provider.

[general]
context=default
useragent=
disallow=all
allow=gsm
allow=alaw
allow=ulaw
language=es
srvlookup=yes
tos_sip = cs3
tos_audio = ef
tos_video = af41
allowguest = yes

register => yourvoipbuster.comuser:PASSWORD@sip1.VoipBuster.com:5060

[phonebooth1]
type=friend
host=dynamic
username=phonebooth1
secret=PASSWORD
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes
[VoipBuster]
type=peer
host=sip1.VoipBuster.com
username=yourvoipbuster.comuser
fromuser=yourvoipbuster.comuser
secret=PASSWORD
context=VoipBuster
insecure=port,invite
qualify=yes
canreinvite=no  

[phonebooth2]
type=friend
host=dynamic
username=phonebooth2
secret=PASSWORD
callerid="Phone booth placed in Y"
context=phonebooths
mailbox=3000@default
qualify=yes


Step by step:

[general]
context=default
useragent=
disallow=all
allow=gsm
allow=alaw
allow=ulaw
language=es
srvlookup=yes
tos_sip = cs3
tos_audio = ef
tos_video = af41
allowguest = yes  

register => yourvoipbuster.comuser:PASSWORD@sip1.VoipBuster.com:5060


Here we are telling the context where the label is (we will see this again in extensions.conf), also which codec types we are allowing (gsm, alaw, ulaw) and the language (spanish, later we'll install the sounds)

The register line has the same data as the [VoipBuster] label. It is needed in some providers.

The ATA adaptor

Image


[phonebooth1]
type=friend
host=ATAIP
username=phonebooth1
secret=PASSWORD
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes

Here we will need to put the adaptor's IP or host name, along with name and password. Another important issue is the context, in this case [voipbuster]

[voipbuster]
type=peer
host=sip1.VoipBuster.com
username=yourvoipbuster.comuser
fromuser=yourvoipbuster.comuser
secret=PASSWORD
context=voipbuster
insecure=port,invite
qualify=yes
canreinvite=no


In this label the important is the host, which is an URL that our provider gives us when we register. We choose VoipBuster for allowing us to make free calls during 120 days paying 10 euros to more than 50 countries


What is the problem with VoipBuster?

They are changing countries' listings without notice, so it's posible that they are taking us some credit.



Configuring another user.

The only different thing from before is the host, which is dynamic, so it can have any IP.

[phonebooth2]
type=friend
host=dynamic
username=phonebooth2
secret=PASSWORD
callerid="Phone booth placed in Y"
context=phonebooths
qualify=yes



EXTENSIONS.CONF


[general]
static=yes
writeprotect=yes

[globals]
phonebooth1=SIP/phonebooth1
VoipBuster=SIP/voipbuster
phonebooth2=SIP/phonebooth2

[default]

[phonebooth1]
include => default
include => nationals
include => echo
include => monkeys 

[phonebooth2]
include => default
include => nationals
include => echo
include => monkeys  

[nationals]  
exten => _9ZXXXXXXX,1,Dial(${VoipBuster}/0034${EXTEN},60,r)
exten => _9ZXXXXXXX,n,Hangup
[eco]
exten => 600,1,Playback(demo-echotest)
exten => 600,n,echo
exten => 600,n,Playback(demo-echodone)
exten => 600,n,Hangup
[monkeys]
exten => 666,1,Answer()
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeysintro)
exten => 666,n,Playback(tt-somethingwrong)
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeys)
exten => 666,n,Hangup 



Step by step:

[general]
static=yes
writeprotect=yes 

[globals]
phonebooth1=SIP/phonebooth1
VoipBuster=SIP/VoipBuster
phonebooth2=SIP/phonebooth2

The original context, where we'll put the options for the extensions.conf file. We protect it and put the variables in globals. It has to be written considering the created users in the sip.conf file. We create 3 variables: one for the ATA adaptor (user phonebooth1 and context phonebooths in the sip.conf, variable phonebooth1), another one for voipbuster and last one for the user that is going to connect by softphones.

[default] 
[phonebooth1]
include => default
include => nationals
include => echo
include => monkeys  

[phonebooth2]
include => default
include => nationals
include => echo
include => monkeys 


These are the contexts from the users that are making the calls, phonebooth1 and phonebooth2. The ISP provider, obviously, will not make calls, we will route them to it instead. The "include" just means that we are adding these contexts (default, nacionales, echo and monkeys).
 
[nationals]
exten => _9ZXXXXXXX,1,Dial(${VoipBuster}/0034${EXTEN},60,tr)
exten => _9ZXXXXXXX,n,Hangup

This is the sintaxis that we'll use for defining what to do when we make a phonecall. For example, here we are defining that when dialing a telephone starting with a 9 and the following number will be bigger than 0 (Z) and the following 7 numbers would be bigger or equal to 0 (XXXXXXX), first (1) dial to the number that we have previously configured as belonging to VoipBuster the number it's been dialed ($EXTEN) adding the countries' international code, (Spain has the 0034). We also tell it to call during 60 seconds and request it to allow the trasfer and not listening the dialling tone (tr). After we tell it that when it will finish with this, to hang up. All of this in just 2 lines!!

Through the DialPlan we could do. i.e.:

[echo]
exten => 600,1,Playback(demo-ecotest)
exten => 600,n,echo
exten => 600,n,Playback(demo-ecodone)
exten => 600,n,Hangup

Here we are teling that for the [echo] context, is the 600 extension. First it will play (Playback) a sound that says that is going to do a echo test with demo-echotest, that is in /var/lib/asterisk/sounds/ or wherever else we have installed it.
Important: the audio format is not needed, Asterisk will choose which is best in every case. After it calls the program that does the echo test, and tells to play to another sound if it decided that the echo test is over. At last stage, it hangs up. About the sintaxis, we could have written this like:

[echo]
exten => 600,1,Playback(demo-ecotest)
exten => 600,2,eco
exten => 600,3,Playback(demo-ecodone)
exten => 600,4,Hangup  


But in this case when we'll want to change it we should renumber it all, that is why is prefered to use the "n" for calling the following action:

[monkeys]
exten => 666,1,Answer()
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeysintro)
exten => 666,n,Playback(tt-somethingwrong)
exten => 666,n,Wait(2)
exten => 666,n,Playback(tt-monkeys)
exten => 666,n,Hangup

Here we tell it to attend, to wait for 2 seconds, to play some sounds (monkeys introduction and another), to wait for 2 seconds, to play another sounds (monkeys!!) and hang up.

The only remaining context in this configuration is [internationals]. Because is a so long configuration that so many people could see we decided to liberate it in the voip-info.org link wiki. For seeing the updated listing for making calls to landlines, click here. link.

All this would agreggate in the extensions.conf and also as "includes" in the user to we want to enable the international calls.

You can read a further configuration of extensions.conf here



Softphone client configuration

EKIGA

Image

It comes with Ubuntu. You can find it in Aplications -> Internet -> Softphone Ekiga,

We will create an account with what we have put in sip.conf, along with the server IP. If we want to connect from internet the needed ports we should open and put the public IP or the domain that we have associated to this.

Account name: phonebooth1 
Protocol: SIP
Registrant: 192.168.10.1
User: phonebooth1
Password: PASSWORD



TWINKLE

Image

Install

  1. sudo aptitude install twinkle

We will open it and will create a new profile using the sip.conf file configuration. The Domain should be our server's IP.

Our configuration will be like this:

Your name: phonebooth1
User name: phonebooth1
Domain: 192.168.10.1
Authentication name: phonebooth1
Password: PASSWORD

After we should see in the Twikle log:

phonebooth, registration succeeded (expires = 3600 seconds)


Configuration of the ATA adaptor.

Image

For configurating the SPA-3102, with a line of exit for making calls and another one of in/out PSTN, that means an a normal telephone line, we should make:

In the navigator we type the IP of the adaptor.

It tells us "spa user". We should login with user and password. User "user" and without password. The page we enter is a information page about the actual configuration.

Go to the admisitrator section, in "Admin login". We type again the user and the password ("admin user"). This time we login like user admin and without password:

From here we can configure:

En Voice -> System we can change the access password (User Password:). Clicking in "Advanced" we can change the admin password too.(Admin Password:)
En Router -> Wan Setup we put an static ip adress inside of our net range. Here we can configurate like router ("PPPoE Settings") too
En Voice -> Line 1 configurating our line for making calls. We should put like the minimum next parameters:
Line enable: yes
SIP Port: 5060
Proxy: ASTERISKIP
Register: yes
Display name: phonebooth1
Configure adaptor ATA 3102 - 1

Password: PASSWORD
Auth ID: phonebooth1
User ID: phonebooth1
Use Auth ID: phonebooth1
Preferred Codec: G711u
Use Pref codec only: no


We can configurate Asterisk in the next way.

[phonebooth1]
type=friend
host=ATAadaptorIP
username=phonebooth1
secret=PASSWORD  n
callerid="Phone booth placed in X"
context=phonebooths
qualify=yes
En Voice -> PSTN Line configurating our PSTN line for make and recieve calls.
SIP Port: 5061

Configure adaptator ATA 3102 - 2

Proxy: ASTERISKIP
Register: yes
Display Name: pstn
Password: PASSWORD
Auth ID: pstn
User ID: pstn
Use Auth ID: no
Preferred Codec: G711a
Use Pref Codec Only: no

We can configure Asterisk in the next way.

[pstn-spa3k]
type=peer
auth=md5
host=ATAadaptorIP
port=5061
secret=PASSWORD 
username=pstn
fromuser=pstn
dtmfmode=rfc2833
context=incoming-pstn
insecure=very




Terminal and logs

Soon we will see in the terminal that Asterisk is completly intuitive and an ally to solve problems. For conecting to the terminal depends on how we begin Asterisk.

First we check if the command is running.

  1. ps auxf | grep asterisk


In case of we can't see, we should connect entering the next command:

  1. /usr/sbin/asterisk -vvvvc


If we begin like daemon, for connecting to the terminal we should enter with the same command, but with the option -r not -c:

  1. /usr/sbin/asterisk -vvvvr


If we have some doubts about this point, you can read the section "Iniciate/Stop Asterisk"

Once inside the terminal you should see the next (Note: CLI means Command Line Interface)
  • CLI>

When an user connects or makes a call we will see that there. I.e. When the user phonebooth1 connects through Twinkle appears the next:

Registered IP 'phonebooth1' at 192.168.10.135 port 5060 expires 3600
Saved useragent "Twinkle/1.2" for peer phonebooth1
[Apr  5 20:01:20] NOTICE[8449]: chan_sip.c:12669 handle_response_peerpoke: Peer 'phonebooth1' is now Reachable. (25ms / 2000ms)


And when he disconnects:

Saved useragent 
Unregistered SIP 'phonebooth1'


When you connected with Ekiga:

Registered SIP 'phonebooth1' at 192.168.10.135 port 5061 expires 3600
Saved useragent "Ekiga/2.0.12" for peer phonebooth1
[Apr  5 20:10:27] NOTICE[[8449]: chan_sip.c:12669 handle_response_peerpoke: Peer 'phonebooth1' is now Reachable. (32ms / 2000ms) 


When you make a call to 666 [monkeys], we see the DialPlan executing in real time:

Executing [666@phonebooth1:1] Answer("SIP/phonebooth1-089832b8", "") in new stack
Executing [666@phonebooth1:2] Wait("SIP/phonebooth1-089832b8", "2") in new stack
Executing [666@phonebooths:3] Playback("SIP/phonebooth1-089832b8", "tt-monkeysintro") in new stack
<SIP/phonebooth1-089832b8> Playing 'tt-monkeysintro' (language 'es')
Executing [666@phonebooths:4] Playback("SIP/phonebooth2-089832b8", "tt-somethingwrong") in new stack
<SIP/phonebooth2-089832b8> Playing 'tt-somethingwrong' (language 'es')
Executing [666@phonebooths:5] Wait("SIP/phonebooth1-089832b8", "2") in new stack
== Spawn extension (phonebooth1, 666, 5) exited non-zero on 'SIP/phonebooth1-089832b8'  

(That doesn't end with all because the user hang on before)

We can see the state of our provider

*CLI> [Apr  5 20:18:36] NOTICE[[28025]: chan_sip.c:12669 handle_response_peerpoke: Peer 'voipbuster' is now Reachable. (90ms / 2000ms) 

Appart of showing us the information in real time, we can ask information and change configuration. For learning how to move inside it our great ally is the Tab key. With that we complete and see what options the command can give us, for example, if we write "sip show" and push the Tab key.

  • CLI> sip show

channel        channels       domains        history        inuse          objects        
peer             peers            registry          settings       subscriptions  user           
users           

That's intuitive and we can reach the diferent dates:

*CLI>  sip show users 
Username                       Secret           Accountcode      Def.Context            ACL  NAT       
phonebooth2                  PASSWORD                            phonebooths           No   RFC3581   
phonebooth1                  PASSWORD                            phonebooths           No   RFC3581  


*CLI> sip show registry 
Host                            Username          Refresh State                Reg.Time                 
sip1.voipbuster.com:5060        phonebooth1       105 Registered           Sun, 05 Apr 2009 20:18:36 
 

*CLI> sip show peers
Name/username                             Host                       Dyn Nat    ACL Port          Status               
phonebooth2/phonebooth2            192.168.10.135            D          5061             OK (4 ms)            
voipbuster/yourvoipbuster.comuser  194.221.62.198                        5060             OK (90 ms)           
phonebooth1/phonebooth1            (Unspecified)                 D                0             UNKNOWN              
3 sip peers [Monitored: 2 online, 1 offline Unmonitored: 0 online, 0 offline]


We can test the DialPlan, for example with the command "console dial 666"

*CLI> console dial 666
No such extension '666' in context 'default'

In this case this doesn't work beacuse we don't have an extension configurated in the default context, but for make tests is recommended type in there (is enough to put it there as "include"). The good thing is that if the server have speakers and microphone we can test it harmlessly.



Further and beyond

Image


Something reamining to see that is very funny to configure is the voicemail.conf and the meetme.conf for i.e. put the sound in spanish.

You can see more information about in the VOIP-info.org wiki. It has detailed information about lots of configuration files and providers, and connect diferent devices and aplications to Asterisk.

If you a are more interested in the learning further about this free IP telephones world the best you can read is the Asterisk book: The Future of Telephony.

You can also join our development group in the free social network n-1.cc

Enjoy
Image

Created by: flawer, Last modification: Thu 03 of Nov, 2011 (17:32 UTC)
Please update this page with new information, just login and click on the "Edit" or "Discussion" tab. Get a free login here: Register Thanks! - Find us on Google+