How to turn your computer into a communications server with Asterisk (VoIP server at home).

Posted: 22 December, 2012 in Computers, Linux
Tags: , , , , , , , , , , , , ,

What is Asterisk?

Asterisk is a complete PBX in software. Works on VoIP protocols, and doesn’t need any external hardware to work. More information on their Web.

What we will do?

We will only configure the server to on the network via IP protocol. You can use with a simple configuration in your intranet or you can buy a subscriber telephone line through one company and get your external number, and use the server to make international calls. More info.
There are many options to install and configure Asterisk on your computer, like downloading ISO with pre-configured software(AsteriskNOW), download versions of the software with some modifications, etc. But we will create our own server from 0 using the Asterisk from Ubuntu repositories installing in Ubuntu 12.10.

The first step is installing the package:

sudo apt-get install asterisk

The default configuration directory of Asterisk is /etc/asterisk/. We will need to modify there sip.conf and extensions.conf files. You don’t need to delete all the pre-configured example configuration (you can do it to prevent other people to access with this parameters) only add these lines to the end of the file:


[1001]                ;username on sip protocol
type = friend
callerid = User One
secret = pass1        ;password on sip protocol
context=home          ;context in extensions.conf
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1001
disallow = all
allow = ulaw
transport = udp

[1002]                ;username on sip protocol
type = friend
callerid = User Two
secret = pass2        ;password on sip protocol
context=home          ;context in extensions.conf
host = dynamic
canreinvite = no
dtmfmode = rfc2833
mailbox = 1001
disallow = all
allow = ulaw
transport = udp


[home]                ;context name
exten => 1001,1,Answer()
exten => 1001,n,Dial(SIP/1001,20,tr)
exten => 1001,n,Hangup

exten => 1002,1,Answer()
exten => 1002,n,Dial(SIP/1002,20,tr)
exten => 1002,n,Hangup

I will explain it a bit. The number between brackets is the username on the sip protocol, this will identify a host into the network. we will create as many users as we want.

In the extensions.conf we associate a number to an action. For example if we dial 1001, it will make 3 actions in order, answer, make the dial with SIP protocol to the specified number and hang up.

Now you need to restart the service daemon so it gets the new configuration files:

sudo service asterisk restart

Now our server is ready to receive connections and make calls between  user1 and user2. The only thing we need to do is set up the soft-phones and register them into the server.

For that we need the soft-phone software to connect,. I will use Zoiper 2.0 Free.

We create a new SIP account into the program. For domain we will put the address of our server, for username we will put the number we put in sip.conf as the sip protocol name, the password we defined on it and the called ID is a non dependent from the server, so we can put the name we want:

zoiper screenshot

Now we only need to register this line and we will be able to make calls to the extensions registered in extensions.conf file.

To test it we only need to call ourselves, for example if you are registered with 1001, just call to 1001, the call will pop up in your own Zoiper.

Making calls to the real telephone network.

If you want to make calls through an internet line to a normal telephone number you only need to add these lines with the information of your line provider to the sip configuration and add in extensions.conf which numbers are associated to these line.

For example, with freecall provider:




exten => _XXXXXXXXX,1,SIPDtmfMode(inband)
exten => _XXXXXXXXX,n,Dial(SIP/0034${EXTEN}@freecall,60)
exten => _XXXXXXXXX,n,Hangup

Any call made to any 9 digits number will be made through freecall SIP provider, adding 0034 (Spain prefix).

Of course you need an account in this provider to works. some of them offer some free calls, just register and give a try.

  1. freefri says:

    Nice explanation about FXO, FXS, PBX, etc (but it is in Spanish):

  2. Loyd says:

    It’s going to be end of mine day, but before ending I am reading this wonderful post to improve my knowledge.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s