[Ref: OpenBSD 5.1, Asterisk 1.8.11 (from ports), Asterisk the Definitive Guide, Secure Communications with OpenBSD and Asterisk, Asterisk: The Future of Telephony, pkg_add(1)]

Table of Contents
  1. Basic Install
  2. Connect a Device
    • SIP
    • IAX
  3. Connect a Call
    • Dialplan

Asterisk has been a maintained package with OpenBSD ports/telephony for a long time. The following will review some installation tips based on the packages and getting a basic configuration up and running.

The OReilly Book: Asterisk: The Future of Telephony is actually still relevant, but you want to use the most current 'online' version which covers Asterisk 1.8, which has some subtle configuration 'advantages' you want to emphasise.

Basic Install

mkdir -p /var/pkg/cache
export PKG_CACHE=/var/pkg/cache
export PKG_PATH=$PKG_CACHE/:non-local/package/repository/

For our configuration, we're installing the following packages, which may have their own dependencies:

  • asterisk
  • asterisk-calendar
  • asterisk-g729
  • asterisk-native-sounds
  • asterisk-odbc
  • asterisk-openbsd-moh
  • asterisk-snmp
  • asterisk-sounds
  • appkonference

The packages install their dependencies and give fair warning of additional information you need to review:

When we/you have an idea what you actually use/need, then we can trim down the above modules, but in our discovery stage we're just putting everything in.

Override Resource Limits

[Ref: login.conf(5)]

Once your PBX system is fully operational, it's going to use up a fair amount of resources, more than the basic service install will use. So, we are going to redefine the resource allocation for Asterisk, and record those changes in the login.conf

File extract: /etc/login.conf

asterisk:\
    :openfiles-cur=512:\
    :openfiles-max=65535:\
    :tc=daemon:

[Ref: cap_mkdb(1)]

Once you've made modification such as the above login.conf, make sure you update the database by executing

$ sudo cap_makedb /etc/login.conf

As per our above configuration in login.conf, you'll want to ensure that your local user account is now connected using the new filesize limits, by using something like vipw, or usermod(8) "-L login-class" to set the login class:

  • _asterisk --> login class --> asterisk
$ sudo usermod -L asterisk _asterisk

vipw File extract /etc/passwd:

_asterisk:*************:545:545:asterisk:0:0:PBX Phone System:/var/spool/asterisk:/bin/ksh

Startup Scripts

[Ref rc.d(8)]

The above installation creates the startup scripts:

  • asterisk
  • netsnmpd
  • netsnmptrapd

stored in /etc/rc.d/

To automatically start/shutdown the daemons during system restarts, reference them in the /etc/rc.conf.locals line

pkgscripts="..."

The 'safe' way for starting, stopping, and reloading Asterisk is with the provided script.

  • /etc/rc.d/asterisk

ReadMe files

Review /usr/local/share/doc/pkg-readmes for:

  • asterisk
  • asterisk-g729

Initial Configuration

[Ref: Install]

The wonderful thing about the packaged system, is that it basically just works. You can refer to the documentation and update the initial configuration, later.

There are apparently different types of ringtones, depending on the country your in, so one of the simple settings is to let Asterisk know what tunes to play when your phone rings.

File: /etc/asterisk/indications.conf

country=au

The "country" option is related to further [au], [gb] tags in the file, so you can't just pick a random two letter acronym and expect it to work.

Initial Startup

Verify installation behaviour by running Asterisk in foreground mode ("-c" control console) with some "-v verbose" output so we can take a peak into it's activities.

$ sudo /usr/local/sbin/asterisk -cvvv

If Asterisk has been successfully installed, you should a screen response such as the below:

...
...
Asterisk Ready.

Run the Asterisk CLI module show command, to list the number of modules installed in your configuration.

Asterisk Ready.
*CLI> module show
... very long list ...
203 modules loaded

Woohoo, Asterisk has been successfully installed, together with some modules we want to use (if we knew how to use them.)

The better way for a clean shutdown (although it will terminate existing calls) is to use the command core stop now

*CLI> core stop now

When we run asterisk (and as per the rc.d(1) rcscripts shown above, we would use /etc/rc.d/asterisk start launched in rc.conf.local or at the command-line:

$ sudo /etc/rc.d/asterisk start

Connect a Device

Before a device can successfully send and recieve calls Asterisk must be made aware of the device, likewise the device needs to be configured to connect with the Asterisk server.

  • Softphones are Software based phones.
  • Hardphones are hardware devices.

Devices connect and communicate with Asterisk over a 'channel'. The two channels we'll review are SIP (configured in sip.conf) and IAX2 (configured in iax.conf)

SIP

[Ref: sip docs]

Extend on the existing sample configuration file:

File: /etc/asterisk/sip.conf

[general]
disallow=all
allow=ulaw

[100]
type=friend
secret=<<something>>
nat=yes
host=dynamic
directmedia=no
qualify=yes
mailbox=100
context=default

Softphone

Configure our softphone to connect to the above server, with the details mentioned for user: 100

Jitsi

We can configure the software SIP client, Jitsi, and monitor the registration process by using the "console" output as above, /usr/local/sbin/asterisk -cvvv

Basic configuration for Jitsi 1.0

  • File --> Add New Account
  • Network: --> select: SIP
  • Username/Password:
    • Username: 100@ip-address-of-asterisk-host
    • Password: <<something>> as above
    • click: Add

After successfully configuring your Jitsi client, you should see the console report:

   -- Registered SIP '100' at my-ip-address:5060
[Mnth DD HH:MM:SS:] **NOTICE**[9939]: **chan_sip.c:20788 handle_response_peerpoke:** Peer '100' is now Reachable.
*CLI> sip show peers
Name/username        Host                          Dyn Forceport   ACL  Port  Status
100/100              (my-ip-address)                D    N              5060  OK (22 ms)
101                  (unspecified)                  D    N              0     UNKNOWN
*CLI> sip show peer 100
Name           : 100
...
...
User Reason    : No
Encryption     : No

Hardphone

IAX

[ Ref: sip.conf]

Softphone

Sample configuration is at: /usr/local/share/examples/asterisk/default/iax.conf

File: /etc/asterisk/iax.conf

[general]
srvlookup=yes
bandwidth=high
jitterbuffer=no
forcejitterbuffer=no
autokill=yes
auth=plaintext
host=dynamic
disallow=all
allow=
[200]

From the asterisk console

module load chan_iax2
Loaded chan_iax2


Connect a Call