VoIP Telephony

Asterisk on OpenBSD

[Ref: OpenBSD 6.5, Asterisk 16.2.1 (from ports) pkg_add(5)]

Using your OpenBSD Host as the office Voice over IP hub has been supported through the Ports system for a good while. Asterisk has been updated regularly for a number of years. The following is one way of getting an Asterisk Private Branch Exchange (PBX) up and running, confirming that the PBX answers your call.

The Internet is your friend, but it can also lead us astray, one thing to look out for is to ensure that the instructions you find are relevant to the version of the software you have installed. Asterisk has been around for a long time and guides relevant for one version can be misleading, totally incorrect when applied to an earlier or later version.

Online Reference documentation that are clear on which versions of Asterisk they document include:

  • The Asterisk Project WIKI
  • The Asterisk Doxygen [1.8 up to 2015]

When in doubt about options/features, the official documentation is a good reference to compare other documentation available on the internet (including this one.)

Package Install

The simplest installation process begins with the OpenBSD package system.

# pkg_add asterisk
quirks-3.124 signed on 2019-04-15T12:10:16Z
Ambiguous: choose package for asterisk
        0: <None>
        1: asterisk-16.2.1
        2: asterisk-16.2.1-imap
Your choice: 1
asterisk-16.2.1: ok
The following new rcscripts were installed: /etc/rc.d/asterisk
See rcctl(8) for details.
New and changed readme(s):

Choice of Sample Configuration Files

File extract: /usr/local/share/doc/pkg-readmes/asterisk

There are several different example configurations provided with this


/usr/local/share/examples/asterisk/openbsd, and installed by default to
/etc/asterisk - an old bare-bones setup provided with the OpenBSD package,
basic voicemail + music-on-hold + 2 phones using the legacy chan_sip module.
basic-pbx is probably now a better starting point, however this is still
kept for simplicity for now.

Before getting fancy, why not see if we can get a basic phone system up and running, using the ‘openbsd’ bare-bones setup.

Start ‘asterisk’ and use “-r” to connect to the running Asterisk application, with a console interface.

# rcctl start asterisk
# asterisk -r
Unable to open specified master config file '/etc/asterisk/asterisk.conf', using built-in defaults
Asterisk 16.2.1, Copyright (C) 1999 - 2018, Digium, Inc. and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
Connected to Asterisk 16.2.1 currently running on XXXX (pid = 36412)

Awesome, Asterisk has launched and successfully put us into the ‘console’

Connecting a ‘phone’

With a PBX that is at least responding, one of the first things we want to confirm is that it can actually connect a device or phone (presumably so we can make phone calls?)

At the Command-prompt CLI> we can look at phone extensions been configured for us, by the sample configuration.

XXXX*CLI> sip show peers
Name/username Host           Dyn Forcerport Comedia    ACL Port     Status      Description           
100           (Unspecified)   D  Yes        Yes            0        UNKNOWN                           
101           (Unspecified)   D  Yes        Yes            0        UNKNOWN                           
2 sip peers [Monitored: 0 online, 2 offline Unmonitored: 0 online, 0 offline]

The response from sip show peers indicates 2 ‘phones’ configured, with no connections.

‘Phones’ or subscribers to our PBX are configured in files for the Channel or Technology used to connect calls. In our example, we’re using the ‘SIP’ Channel, so we can look at the configuration file:

File extract: sip.conf

; Phone #1

; Phone #2

The key part, for now, is to know that the password and user-id (inside the square [brackets]).

We use the user-ids, and passwords to configure two clients, to see whether they

a. can connect to the pbx
b. can be 'connected', make calls, to each other.
Connecting to the PBX

Also known as the basic configuration for Jitsi

We’ve found these instructions should be similar across any SIP Client, where you need to create an account connection between the client and the server.

  • File –> Add New Account
  • Network: –> select: SIP
  • Username/Password:
    • SIP id: 100@ip-address-of-asterisk-host
    • Password: password discovered 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.

You can also see the change, when viewing the ‘sip’ connections.

XXXX*CLI> sip show peers
Name/username Host            Dyn Forcerport Comedia    ACL Port     Status      Description           
100/100  D  Yes        Yes            5060     OK (12 ms)                        
101           (Unspecified)    D  Yes        Yes            0        UNKNOWN                           
2 sip peers [Monitored: 1 online, 1 offline Unmonitored: 0 online, 0 offline]
Checking the Sound

We can verify that audio is travelling from the PBX to our client by dialling the configured VoiceMail Service at *99

File extract: extensions.conf

exten => *99,1,VoiceMailMain(${FILTER(0-9,${CALLERID(NUM)})})

exten => *98,1,Answer()
exten => *98,n,ConfBridge(*98,c,M)

exten => _XXX,1,Dial(SIP/${FILTER(0-9,${EXTEN})},12,tr)
exten => _XXX,n,Voicemail(${FILTER(0-9,${EXTEN})})
exten => _XXX,n,Hangup

Dialing *99, will send the caller to the VoiceMailMain(xxx) function and will provide a ‘voice’ prompt. The basic password is 1234

This gives us the confidence that we can connect from the ‘phone’ to Asterisk and we can hear messages from the Asterisk server.

It is not a firm test that we can talk through the server, so the next test requires a small addition to the /etc/asterisk/extensions.conf file.

Add the following lines to extensions.conf.

; Create an extension, 600, for evaluating echo latency.
exten => 600,1,Playback(demo-echotest)  ; Let them know what's going on
 same => n,Echo()                   ; Do the echo test
 same => n,Playback(demo-echodone)  ; Let them know it's over
 same => n,Hangup()

Back at the console, we can reload the configuration file by using ‘dialplan reload’

XXXX*CLI> dialplan reload
Dialplan reloaded

You can now dial “600” to verify that you can talk to the Asterisk box, and the Asterisk box can talk back to you (which you knew from the VoiceMailBox test earlier).


Once you have two ‘phones’ connected, you may find that Asterisk complains about DNS errors, such as below:

ast_sockaddr_resolve: getaddrinfo("your-hostname", "(null)", ...): no address associated with name
acl.c:972 ast_ouraddrfor: Cannot connect to Can't assign requested address

[Ref: resolv.conf(5)]

DNS, Name Resolution matters. Make sure you have configured your name resolution correctly.

File extract: /etc/resolv.conf

search example.com
nameserver ip-address-1
nameserver ip-address-2
lookup file bind

[Ref: hostname.if(5)]

File extract: /etc/hostname.nic1

inet host-ip-address host-ip-netmask host-ip-broadcast

[Ref: hosts(5)]

File extract: /etc/hosts       localhost
::1             localhost
host-ip-address pbxhost.example.com pbxhost

Update log rotation

From the pkg-readme file.

Asterisk logs to /var/log/asterisk/messages by default; log rotation
can be handled by adding a line like the following to /etc/newsyslog.conf:

/var/log/asterisk/messages              640  5     1000 *     Z "asterisk -rx 'logger reload'"

Enable Auto-start

# rcctl enable asterisk
# cat /etc/rc.conf.local


Hopefully the above has provided you with some assistance in getting Asterisk up and running on your preferred Operating System.

This is only the beginning.