Installing and Configuring Asterisk 18 (with Softmodem) on Ubuntu 20

Update and install the dependencies needed to build Asterisk.

# apt update
# add-apt-repository universe
# apt -y install git curl wget libnewt-dev libssl-dev libncurses5-dev subversion libsqlite3-dev build-essential libjansson-dev libxml2-dev  uuid-dev 

Download Asterisk 18 and unpack.

# cd ~
# wget
# tar xvf asterisk-18-current.tar.gz

Download the MP3 decoder library.

# cd asterisk-18.*/
# contrib/scripts/

Resolve any dependencies.

# sudo contrib/scripts/install_prereq install

Download the Softmodem code and copy it to the Asterisk.

# cd ~
# wget

Copy app_softmodem.c to the ”apps” folder of the Asterisk 18 source e.g.

# cp app_softmodem.c ./asterisk-18.13.0/apps

Build Asterisk. Note that on a Raspberry PiOS you may have to specifically install g++.

# cd asterisk-18.*/
# ./configure

When compiling on a Raspbery Pi 4, ./configure has been known to fail with errors relating to /lib/cpp. If this occurs, it may be that the g++ package needs to be installed.

# make menuselect

If this works you will be presented with a menu. If you do not know what to do with this, simply Save and Exit.

# make
# make install


sudo make progdocs

Create the configs etc.

# make samples
# make config
# ldconfig

Create an Asterisk user and Configure.

# groupadd asterisk
# useradd -r -d /var/lib/asterisk -g asterisk asterisk
# usermod -aG audio,dialout asterisk
# chown -R asterisk.asterisk /etc/asterisk
# chown -R asterisk.asterisk /var/{lib,log,spool}/asterisk
# chown -R asterisk.asterisk /usr/lib/asterisk
# vim /etc/default/asterisk
# vim /etc/asterisk/asterisk.conf

  runuser = asterisk ; The user to run as.
  rungroup = asterisk ; The group to run as.x

Start Asterisk.

# systemctl start asterisk
# systemctl status asterisk

Once you are happy things are OK then enable.

# systemctl enable asterisk

Connect to the Asterisk CLI, the more ‘v’s the more verbose (I think the max is 10!).

# asterisk -rvvv


CLI> pjsip show endpoints
No objects found.

Journal entries can be viewed with the following command (x = extra detail, e = jump to the end, u = the unit to view).

# journalctl -xeu asterisk

For the firewall you may need to open some ports for SIP and RTP depending on what provider is used for a SIP Trunk. e.g.

ufw allow proto tcp from <ipaddress_of_SIP_provider> to any port <SIP Port Range Start>:<SIP Port Range End>
ufw allow proto udp from <ipaddress_of_SIP_provider> to any port <RTP Port Range Start>:<RTP Port Range End>


ufw allow proto udp from to any port 5000:31000
ufw allow proto udp from to any port 5000:31000

In addition any cloud provider such as DigitalOcean may also have firewall rules that need altering.


This config filer replaces ”sip.conf” which has been deprecated. This will depend upon the SIP Trunk provider that is used.

This particular setup was used successfully with the free Sipgate Basic product. This is not supported by Sipgate and is not recommended either. However, it does work with the restriction that there can be only one incomming connection at a time.

type = transport protocol = udp bind =
type = registration 
retry_interval = 20 
max_retries = 10 
contact_user = <sip_user_id> 
expiration = 120 
transport = transport-udp 
outbound_auth = telstar 
outbound_proxy = 
client_uri = sip:<sip_user_id> 
server_uri =
type = auth 
auth_type = userpass 
username = <sip_user_id> 
password = <sip_password> 
realm =
type = aor 
contact = sip:<sip_user_id>
type = endpoint 
context = from-external 
disallow = all 
allow = alaw 
from_user = <sip_user_id> 
from_domain = 
outbound_auth = telstar 
aors = telstar
type = identify 
endpoint = telstar 
match =


Note that the Dialplan below increases the TX and RX volume, this was needed for use with Telstar. See note below.

exten => telstar,1,Set(VOLUME(TX)=2)
exten => telstar,n,Set(VOLUME(RX)=2)
exten => telstar,n,Answer()
exten => telstar,n,Softmodem(, 6503, ,v(V23)ld(7)s(1)e)
exten => telstar,n,Hangup()

However, it does add extra cpu processing and should only be added if needed.

In the above example dialplan the volume has been increased. The default setting is zero 0 which disables the calling volume adjustment routine. To increase the volume set the adjustment to integer greater than or equal to 2, similarly, to decrease the volume set the adjustment to integer less than or equal to -2. Thankyou to AndyDev ( for the explanation and for the following examples.

Using adjustment value of -1 or 1 has no effect on the resulting volume but wastes CPU cycles, use zero 0 instead.


; Reduce each sample to 50% the original value
same => n,SET(VOLUME(TX)=-2)

; Reduce each sample to 20% the original value
same => n,SET(VOLUME(TX)=-5)

; Reduce each sample to 10% the original value
same => n,SET(VOLUME(TX)=-10)

; Disable volume adjustments
same => n,SET(VOLUME(TX)=0)

; Increase each sample to 200% of the original value
same => n,SET(VOLUME(TX)=2)