Asterisk is a free telephony software. I’m posting here sample commented configuration files for reference purposes, hoping they will help you get kickstarted if needed.

This config sets up :

SIP phones (for softphones or harware phones with SIP capabilities)

Voice mails

A few test phone numbers

Forwarding of calls to a SIP provider for outbound and incoming calls (from/to PSTN)

That should be plenty already for a SOHO environment !

Note to French readers : Si votre FAI est Free, cette configuration fonctionne pour passer / recevoir des appels via le SIP de Free (Freephonie).

SIP configuration

SIP configuration (for softphones / SIP hardware phones, as well as outbound / incoming PSTN calls to/from an SIP-to-PSTN gateway provider) is performed in the /etc/asterisk/sip.conf file.

Here is an example :

# cat sip.conf [general] defaultexpiry=1800 dtmfmode=auto qualify=yes register => 09510XXXXX:ProviderPassword@freephonie.net ; selecting CODECs disallow=all allow=ulaw allow=alaw allow=speex allow=gsm language=fr [freephonie] ; Outbound phone calls SIP configuration type=friend host=freephonie.net username=09510XXXXX fromuser=09510XXXXX secret=ProviderPassword nat=yes insecure=port,invite fromdomain=freephonie.net context=fromfree [client1] ; Softphone declaration type=friend username=client1 secret=Password01 host=dynamic context=home nat=yes ; connexion is allowed from NATted networks [client2] ; 2nd softphone declaration type=friend username=client2 secret=Password02 host=dynamic context=home nat=yes

Dialplan configuration

Next you’ll need to setup a dialplan so that calls are routed as you wish.

The dialplan is setup in the /etc/asterisk/extensions.conf.

; context for local SIP clients [home] ; if 101 is dialed then send it to SIP client1, wait 15 sec for a ; pick up, then send it to voicemail exten => 101,1,Dial(SIP/client1,15) exten => 101,n,Wait(1) exten => 101,n,VoiceMail(101@voicemails) exten => 101,n,PlayBack(vm-goodbye) exten => 101,n,Hangup() ; 201 phone number will lead to the 101 voicemail menu exten => 201,1,VoiceMailMain(101@voicemails) exten => 201,n,Hangup() ; same setup for 102 as for 101 exten => 102,1,Dial(SIP/client2,15) exten => 102,n,Wait(1) exten => 102,n,VoiceMail(102@voicemails) exten => 102,n,PlayBack(vm-goodbye) exten => 102,n,Hangup() ; 202 phone number will lead to the 102 voicemail menu exten => 202,1,VoiceMailMain(102@voicemails) exten => 202,n,Hangup() ; outbound calls : ; if dialing a 0 starting phone number, remove the leading 0 and patch it ; through the freephonie link (SIP-to-PSTN gateway service) exten => _0.,1,Dial(SIP/freephonie/${EXTEN:1}) ; misc testing stuff ; when dialing 500, Asterisk will pick up and count 1,2,3 before hanging up exten => 500,1,Answer exten => 500,n,Wait(2) exten => 500,n,SayDigits(123) exten => 500,n,Hangup ; when dialing 501, Asterisk will pick up and repeat everything you say with ; as less delay as possible. Good to assess line latency. exten => 501,1,Answer() exten => 501,n,Playback(welcome) exten => 501,n,Playback(demo-echotest) exten => 501,n,Echo() exten => 501,n,Playback(demo-echodone) exten => 501,n,Playback(vm-goodbye) exten => 501,n,Hangup() [fromfree] ; Context of inbounds call coming from freephonie.net ; rings both client1 and client2 for 10 secs, then send it to congestion. ; congestion is when all the lines are busy. ; in this case freephonie.net will sent it to its voicemail system exten => s,1,Dial(SIP/client1&SIP/client2,10) exten => s,2,Congestion() exten => s,3,Hangup()

Voicemail configuration

Finally, let’s see the voice mailboxes configuration. They are setup in the /etc/asterisk/voicemail.conf.

[voicemails] ; 101 is the voicemailbox number, 1234 is the password, client1 is the matching client, ; and the email address is to whom to send the audiofile. 101 => 1234,client1,client1@sakana.fr 102 => 5678,client2,client2@sakana.fr