Guide to install and configure Asterisk in CentOS 6.6

Asterisk_Logo.svg

To begin I will give a brief description of what it is Asterisk in case someone doesn't know.

  • Asterisk is a free software created by Mark Spencer founder of the company Digium the main developer, which performs functions of PBX. Una PBX in short, it is a telephone exchange.
  • Asterisk allows you to manage calls, mailboxes, create a IVR (Interactive voice response) between many other things.
  • It recognizes a lot of protocols VoIP (Voice over IP) among which are SIP e IAX which are the most important.

Now that we know about Asterisk let's install and configure it for a CentOS 6.6 server

The installation part is different depending on the distro we use but the configuration is the same for Ubuntu, CentOS, Debian, etc.

Installation

The first thing we are going to do is add the repository inside /etc/yum.repos.d/ :

  • The first repository that we are going to introduce will be: centos-asterisk.repo

[asterisk-tested] name=CentOS-$releasever - Asterisk - Tested
baseurl=http://packages.asterisk.org/centos/$releasever/tested/$basearch/
enabled=0
gpgcheck=0
#gpgkey=http://packages.asterisk.org/RPM-GPG-KEY-Digium

[asterisk-current] name=CentOS-$releasever - Asterisk - Current
baseurl=http://packages.asterisk.org/centos/$releasever/current/$basearch/
enabled=1
gpgcheck=0
#gpgkey=http://packages.asterisk.org/RPM-GPG-KEY-Digium

  • The second repository will be: centos-digium.repo

[digium-tested] name=CentOS-$releasever - Digium - Tested
baseurl=http://packages.digium.com/centos/$releasever/tested/$basearch/
enabled=0
gpgcheck=0
#gpgkey=http://packages.digium.com/RPM-GPG-KEY-Digium

[digium-current] name=CentOS-$releasever - Digium - Current
baseurl=http://packages.digium.com/centos/$releasever/current/$basearch/
enabled=1
gpgcheck=0
#gpgkey=http://packages.digium.com/RPM-GPG-KEY-Digium

Once this is finished we do a
yum update

Now we will install the package asterisknow-version.noarch

yum install asterisknow-version

Installing this package we add the rest of the Asterisk repositories, with all their available versions. Now we will see that new files have been created in the /etc/yum.repos.d folder. We are going to install the version 13 de Asterisk.

To choose a specific version (by default it uses the repository of version 11) we use the parameter –enablerepo (it enables the repository that we indicate) in the installation with yum, that is, we can install any version indicating the appropriate repository
yum install asterisk asterisk-configs asterisk-sounds-core-es-gsm --enablerepo=asterisk-13

How are we going to install the latest version of Asterisk, we will enable the default repository to update Asterisk to be centos-asterisk-13.repo.

To do this we modify the enabled parameter of the repository centos-asterisk-11.repo a 0, so that it is disabled. And in the same way, we modify the enabled parameter of the repository centos-asterisk-13.repo a 1, so it will become the repository used for updates to Asterisk. Depending on the version that we have installed, we will enable the repository of our version.

Configuration

We go to the configuration folder that is in / etc / asterisk

cd /etc/asterisk/

We will find many files of which right now we will use three:

  • sip.conf → In it the SIP users that we are going to use are registered
  • extensions.conf → In it we register the extensions
  • voicemail.conf → In it we register the mailboxes

We start with the file sip.conf

We go down to the end of the file or wherever we want, we choose the end for the convenience of knowing where they always are. And we continue the following structure for each user:

[ejemplo] type=friend
secret=pass
qualify=yes
nat=no
host=dynamic
canreinvite=no
context= contexto
mailbox= buzon

  • We must put the User nameIn this case example
  • La password of the user is put in secret
  • En host we have decided to put dynamic so that the user can connect from any IP on the network
  • Context is the context, we put the context in which it will be
  • Mailbox it's voicemail

Now I am going to leave you an example of what I have done
[rack] type=friend
secret=1234
qualify=yes
nat=no
host=dynamic
canreinvite=no
context=iesjg
mailbox=00@buzon

Over the line 343 of the sip.conf we establish language = isWith this we make all the users that we believe have Spanish as their default language.

Now we are going to configure the voicemail.conf

To configure the mailboxes we go down to the bottom and create a context, for example [mailbox] and thus configure the mailboxes with the following structure:
número => pass,nombre,correo

And now the example that I have done:

00 => 1234,rack,rack@iesjorgeguillen.es

Already for last let's configure the extensions.conf

At the bottom of the document, in my case, I will add the configuration

We will create a context in my case [iesjg], remember that the contexts are in brackets.

And now within that context we will create extensions such as:
exten => 00,1,Dial(SIP/rack,15,Ttm)
same => n,VoiceMail(00@buzon)
same => n,Hangup()

  • What it does is every time they call extension 00 first it calls the SIP / rack (which is created in sip.conf) for 15 seconds with background music and the call can be forwarded to another phone
  • We use "Same" to avoid having to be putting "exten => 00"
  • If not answered, in the next place "n”Skip the mail with the function VoiceMail (00 @ mailbox) previously set to voicemail.conf
  • And finally we do a Hangup () to hang

Now I am going to put some useful Asterisk functions.

  1. Dial()

  • With this function, make a call to where we pass in this case SIP / rack

  1. Voicemail()

  • With this function the voice mailbox of that user is called to leave a message (mailbox number@contexto_en_voicemail.conf)

  1. hang-up()

  • With this function we hang up.

  1. Wait()

  • With this function a wait is carried out, the time we want to pass Wait (1), wait 1 second.

  1. VoiceMailMain()

  • Call to menú of the voicemail, it will ask you the extension and its password to listen to the messages.

  1. Answer()

  • With this function the Asterisk PBX answers the call.

  1. All time lap record()

  • With this function an audio is recorded. For example to create a menu.

  1. background()

  • Play an audio in the background.

Now we restart the service.
service asterisk restart

And now we run the asterisk console to carry out monitoring.

asterisk -rvvvvvvvvvvv

When we connect phones with the created SIP users we can see them in the console by executing:

sip show peers


Leave a Comment

Your email address will not be published. Required fields are marked with *

*

*

  1. Responsible for the data: Miguel Ángel Gatón
  2. Purpose of the data: Control SPAM, comment management.
  3. Legitimation: Your consent
  4. Communication of the data: The data will not be communicated to third parties except by legal obligation.
  5. Data storage: Database hosted by Occentus Networks (EU)
  6. Rights: At any time you can limit, recover and delete your information.

  1.   Frank said

    Fantastic explanation. I will test it with my cycle students, to see if they are able to configure it ...

    1.    bynikiyo said

      Thank you very much for the comment, I am a middle school student so they should also be able to 🙂

  2.   cristian said

    : clap

    this application is always necessary, and those who want to install it many times are shipwrecked

    : clap

    1.    bynikiyo said

      Yes, although I could have gone into more about the types of codecs that can be used, the types of audio files and some other extensions. But I wanted to make it easy, straightforward, and work.

  3.   dwarf said

    Great but from what I see this application only allows calls from one computer to another within a local network.

    When I said that it was a switchboard, I thought that, by installing some kind of hardware, it allowed making calls to landline or mobile phone numbers and at the same time being able to receive them.

    I don't know, something that would allow having a customer database and being able to call them by phone from the same computer while you are writing down data or orders, etc.

    Something in the telemarketing plan.

    1.    toni said

      Exactly this can be done, and yes, you need specific hardware, sold for example by Digium (the same company created by who created Asterisk and that maintains the project) on its website (or others as it is free hardware), to be able to use the RTB (Basic Telephone Network). You can make both local calls and from one telephone of one switchboard to another phone of another interconnected switchboard or go out to the RTB. You can also use normal landlines (RJ11). You need to have a contracted telephone line, since going to the RTB has a cost, what it would cost you to call from your own landline and depending on the plan you hire and the numbers you have, you can make more or less simultaneous calls, on the contrary if You do everything through the Internet, the cost will be 0 since it is not necessary to go out to RTB and everything goes on the Internet! a greeting

      1.    dwarf said

        Ok thanks for the information.

        I'll look at it calmer as soon as I have time.

        The truth is very interesting.

  4.   Manuel said

    Hello, I followed the tutorial but dahdi does not appear in the configuration files or as a daemon in the system, could you explain if this configuration structure changes for asterisk 13? or tell me how can I add dahdi? ... it can't find the files to perform an installation with Asterisk 1.8

    1.    Manuel said

      I was checking more and I was able to get it, to install dahdi you have to install the dahdi-tools and dahdi-linux-devel packages then dahdi appear both as a daemon and as a configuration file with the name dahdi-channels.conf

  5.   Luis said

    Man, the tutorial is basic like just ...

    As a practice it is not worth much either, it stays a lot on the surface, the dialplan only receives calls.

    Too basic.

    1.    Manuel said

      The goal of the tutorial is not to build DialPlan or show the many functionalities of Asterisk.
      Apparently these are the repositories of the AsteriskNow distribution because it has freepbx 2.11 in its repositories, Asterisk 1.8 is not found, but the Asterisk 1.8 packages are in the Epel Repositories, the tutorial is very good because it complies in a simple way the Asterisk installation is version 11,12, and 13, you also have to enable the Digium repositories of the Asterisk version that is installed, of course you have to add the dahdi-tools and dahdi-linux packages to the installation statement. devel to install Dahdi, keep in mind that the versions of dahdi and libpri are currently stable versions because installing the latter from the source codes are more recent versions

  6.   phyto said

    Very cool and simple, being the first of asterisk it seems good to start like this.
    For the next one, obviously, go higher.

  7.   edwin vasquez said

    I followed the guide but I have a conflict with some bookstores. Any help thanks.

    -> Package libopenr2.x86_64 0: 1.2.0-1_centos6 will be installed
    -> Package libpri.x86_64 0: 1.4.14-1_centos6 will be installed
    -> Package libss7.x86_64 0: 1.0.2-1_centos6 will be installed
    -> Dependency resolution finished
    Error: Package: asterisk-core-13.3.0-1_centos6.x86_64 (asterisk-13)
    You need: libg7221codec.so.2 () (64bit)
    Disponible: pjproject-2.1-0.digium2.1_centos6.x86_64 (asterisk-current)
    libg7221codec.so.2 () (64bit)
    Disponible: pjproject-2.3-0.digium2.1_centos6.x86_64 (asterisk-current)
    libg7221codec.so.2 () (64bit)
    Disponible: pjproject-2.3-0.digium3.1_centos6.x86_64 (asterisk-current)
    libg7221codec.so.2 () (64bit)
    Instalado: pjproject-2.3-5.el6.x86_64 (@epel)
    Not found
    Disponible: pjproject-2.1-0.digium1.1_centos6.x86_64 (asterisk-current)
    Not found
    Disponible: pjproject-2.1-0.digium1.2_centos6.x86_64 (asterisk-current)
    Not found
    Error: Package: asterisk-core-13.3.0-1_centos6.x86_64 (asterisk-13)
    You need: libilbccodec.so.2 () (64bit)
    Disponible: pjproject-2.1-0.digium2.1_centos6.x86_64 (asterisk-current)
    libilbccodec.so.2 () (64bit)
    Disponible: pjproject-2.3-0.digium2.1_centos6.x86_64 (asterisk-current)
    libilbccodec.so.2 () (64bit)
    Disponible: pjproject-2.3-0.digium3.1_centos6.x86_64 (asterisk-current)
    libilbccodec.so.2 () (64bit)
    Instalado: pjproject-2.3-5.el6.x86_64 (@epel)
    Not found
    Disponible: pjproject-2.1-0.digium1.1_centos6.x86_64 (asterisk-current)
    Not found
    Disponible: pjproject-2.1-0.digium1.2_centos6.x86_64 (asterisk-current)
    Not found
    You could try using the –skip-broken command to get around the problem
    You could try running: rpm- Va –nofiles –nodigest

    1.    bynikiyo said

      Sorry for not answering before, I had read it and I was going to answer it when I used the pc, I think you should disable the epel repos or install the asterisk with enablerepo = »repoqueuses» because at least epel is giving you problems here. I would also uninstall the libraries you have and give problems and let asterisk install them by themselves.

  8.   falls said

    Hi, look, we have a problem with this, we installed asterisk and the whole story, we configured the switchboard and the phones, the phones are registered, but we can't call between them, do you know what the problem could be?

    1.    bynikiyo said

      Well, I don't know. In theory, if they are registered, they should be able to call each other. Doesn't the log of the switchboard tell you anything? PS: sorry for replying so late