- 2.1 Installing Asterisk on the Server
- 2.2 Calling "Hello World" from the CLI
- 2.3 Calling "Hello World" with a SIP Phone
- 2.4 Building a Minimal Phone System with Two SIP Phones
- 2.5 Rights Administration with Contexts
- 2.6 Calls to and from the Public Switched Telephone Network
2.4 Building a Minimal Phone System with Two SIP Phones
What does the simplest possible working Asterisk system look like? Two phones and one Asterisk server.
We've already worked with all the individual pieces of this puzzle, and now we just have to put them together. To start, we configure two SIP phones in /etc/asterisk/sip.conf:
[general] port=5060 bindaddr=0.0.0.0 [2000] type=friend secret=1234 host=dynamic [2001] type=friend secret=1234 host=dynamic
Next, we have to make extensions that call the SIP phones in /etc/asterisk/extensions.conf. We will leave the "Hello World" example in place for testing purposes; we can verify that each phone is working by dialing 1001 and listening for the "Hello World" message. The resulting dialplan looks like this:
[default] exten => 1001,1,Answer() exten => 1001,2,Playback(hello-world) exten => 1001,3,Hangup() exten => 2000,1,Dial(SIP/2000) exten => 2001,1,Dial(SIP/2001)
Restart Asterisk and the phones (which you configure following the instructions in the previous section). After the phones have registered, you can call one phone from the other, or you can call the test extension from either phone.
2.4.1 Configuring Voicemail
Asterisk already includes a working voicemail module. We need only configure it for use via the /etc/asterisk/voicemail.conf file. First, we move the existing sample file to our sample backup directory:
debian:/etc/asterisk# mv voicemail.conf /var/tmp/asterisk-etc-backup/
Now we create a new /etc/asterisk/voicemail.conf file and enter the following:
[general] format = wav [default] 2000 => 4711,Joe Bloggs,jbloggs@example.com 2001 => 0815,Daisy Duke,daisy.duke@hazzard.com
Now the mailboxes are configured (yes, it really is that easy). Each entry starts with the access password, then the full name of the user, and finally the user's e-mail address. The final step is to add a few more lines to /etc/asterisk/extensions.conf to attach this voicemail functionality to our telephones. Don't forget to add ,20 to Dial() :
[default] exten => 1001,1,Answer() exten => 1001,2,Playback(hello-world) exten => 1001,3,Hangup() exten => 2000,1,Dial(SIP/2000,20) exten => 2000,2,VoiceMail(2000,u) exten => 2001,1,Dial(SIP/2001,20) exten => 2001,2,VoiceMail(2001,u) exten => 2999,1,VoiceMailMain(${CALLERID(num)},s)
Done! Start Asterisk with asterisk -vvvvvc and call one phone from the other. (In a running Asterisk, typing reload in the Asterisk CLI is sufficient to apply any changes to the configuration files.) After 20 seconds of ringing (the reason for the ,20 in Dial() ), you are transferred to the voice mailbox. If the called station is busy, the call goes directly to the voice mailbox. Dial 2999 from any phone and you can access the voicemail menu for that phone.
If you want to secure your mailboxes with passwords, or would like to review the voicemail menus, see Chapter 9, "Voicemail."