Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Modified the tutorial to allow for chan_pjsip as well as chan_sip

...

You've just installed Asterisk and you have read about basic configuration. Now let's quickly get a phone call working so you can get a taste for a simple phone call to Asterisk.

Hello World with Asterisk

...

and SIP

Requirements

This quick tutorial assumes you the following:

  • You have a SIP phone plugged into the same LAN where the Asterisk server is plugged in

...

  • , or can install the Zoiper softphone used in the example
  • If you use your own hardware phone, we assume both the phone and Asterisk can reach each other and are on the same subnet.

Configuration files needed

...

  • asterisk.conf
  • modules.conf
  • extensions.conf
  • sip.conf or pjsip.conf

You can use the defaults for asterisk.conf and modules.conf, we'll only need to modify extensions.conf and sip.conf or pjsip.conf.

To get started, go ahead and move to the /etc/asterisk/ directory where the files are located.

...

No Format
[from-internal]
exten = 100,1,Answer()
same = n,Wait(1)
same = n,Playback(hello-world)
same = n,Hangup()

When a phone dials extension 100, we are telling Asterisk to Answer the call, Wait one second, then Play (Playback) a sound file (hello-world) to the channel and Hangup.

Configure a SIP channel driver

Depending on the version of Asterisk in use, you may have the option of more than one SIP channel driver. You'll have to pick one to use for the example.

Info
  • Asterisk 11 and previous: chan_sip is the primary option.

...

...

  • Asterisk 12 and beyond: You'll probably want to use chan_pjsip (the newest driver), but you still have the option of using chan_sip as well

Follow the instructions below for the channel driver you chose.

Configure chan_sip

Backup and edit a new blank sip.conf, just like you did with extensions.conf.

...

Basic configuration will be explained in more detail in other sections of the wiki. For this example to work, just make sure you have everything exactly as written above. For the sake of terminology, it is useful to note that though we have this SIP configuration configured with "type=friend", most people refer to this as configuring a SIP peer.

Configure chan_pjsip

Backup and edit a new blank pjsip.conf, just like you did with extensions.conf.

Then add the following to your pjsip.conf file:

No Format
[transport-udp]
type=transport
protocol=udp
bind=0.0.0.0

[6001]
type=endpoint
context=from-internal
disallow=all
allow=ulaw
auth=6001
aors=6001

[6001]
type=auth
auth_type=userpass
password=unsecurepassword
username=6001

[6001]
type=aor
max_contacts=1

Configure your SIP phone

You can use any SIP phone you want of course, but for this demonstration we'll use Zoiper, a Softphone which just happens to be easily demonstrable.

...

Back at the Linux shell go ahead and start Asterisk.

No Format
asterisk -cvvvvv

We'll start Asterisk with a control console (-c) and level 5 verbosity (vvvvv).

No Format
asterisk -cvvvvv

Or if Asterisk is already running, restart Asterisk from the shell and connect to it.

No Format
asterisk -rx "core restart now"
asterisk -rvvvvv

Make the call

Go back to the main Zoiper interface, and make sure the account is registered. Select the account from the drop down list and click the Register button next to it. If it says registered, you are good to go. If it doesn't register, then double check your configuration.

...