How to Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server)

How to Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server). Asterisk is a powerful and versatile open-source VoIP server ideal for small businesses.

Asterisk supports the most common protocols and can be used with any data connection, including DSL, cable modem, ISDN, Wi-Fi and Bluetooth. In this tutorial, we will show you how to install Asterisk on your Ubuntu 20.04 system.

What is Asterisk

Asterisk is an open-source PBX and VoIP (Voice over IP) application that allows you to easily install, maintain and run a fully managed IP telephony system.

Asterisk uses a mix of open-source software and proprietary components to provide VoIP services. It allows users to make, receive, and manage telephone calls over IP based networks and traditional analog lines, using SIP protocol or VoIP services, using a computer or smartphone.

Asterisk also provides advanced features such as content filtering, call routing, and notification services for both PSTN and SIP traffic. It is ideal for businesses that require flexible enterprise telephony functionality at competitive costs.

It can be used in almost any network environment, including small businesses, hospitals, school districts, and large corporations.

Asterisk is free of charge, with all proprietary code included in the source tree, so you can modify and/or install it on your servers. The Asterisk is available for all major operating systems like Linux, Microsoft Windows Server 2003/2008/2012 Server family, FreeBSD, and Mac.

In this blog post next about Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server) we shall learn Asterisk features.

Benefits of Asterisk

 Asterisk is a communications software that allows you to run both your telephone network and VoIP services. It has many advantages over other traditional solutions, including:

  • Asterisk allows users to make and receive phone calls, send and receive faxes, and record their voice messages.
  • Asterisk can route all your calls through the same number.
  • It has no license fees.
  • Asterisk has a built-in voice mail system that stores messages and provides an easy interface for retrieving them.
  • It is highly flexible and can be integrated with other systems, such as email servers and SQL databases.
  • Asterisk is highly customizable, with many extensions and features.

Follow this post to learn how to install Asterisk Server on Ubuntu 20.04.

Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server)

Asterisk has no official repository, so you need to compile and install Asterisk from its Github source code. But before diving into installation, you need to resolve dependencies.

Update and Install Dependent Packages

First of all, update your system to ensure all packages are up to date.

				
					sudo apt update
				
			

Next, you need to install the dependent packages that are needed for Asterisk installation.

				
					 sudo apt install wget build-essential git autoconf subversion pkg-config libtool -y
				
			

Output:

				
					Reading package lists... Done
Building dependency tree       
Reading state information... Done
pkg-config is already the newest version (0.29.1-0ubuntu4).
pkg-config set to manually installed.
…

				
			

Compile and Install DAHDI and LibPRI

The LibPRI library is used to communicate with ISDN connections, and DAHDI enables Asterisk to communicate with analog and digital telephones. So you need to install it on your system.

DAHDI

You have to compile and install two DADHI Github repositories, dahdi-linux and dahdi-tools

Clone the dahdi-linux repository with the following command.

				
					sudo git clone -b next git://git.asterisk.org/dahdi/linux dahdi-linux
				
			

Next, navigate to the source code folder and compile it with the following commands.

				
					cd dahdi-linux
sudo make

				
			

Now, install the DADHI using the following command.

				
					sudo make install
cd.. 

				
			

Similarly, compile dahdi-tools using the following commands.

				
					sudo git clone -b next git://git.asterisk.org/dahdi/tools dahdi-tool
cd dahdi-tools
sudo autoreconf -i
sudo ./configure
Now, compile and install dahdi-tools with the following commands.
sudo make install
sudo make install-config
sudo dahdi_genconf modules
cd .. 

				
			

LibPRI

Clone and install LibPRI from its source code using the following commands.

				
					sudo git clone https://gerrit.asterisk.org/libpri libpri
cd libpri
sudo make
sudo make install

				
			

Now that these libraries are installed, you can move on to compiling and installing Asterisk on your Ubuntu system.

Compile and Install Asterisk

Clone Asterisk Repository

Clone the source code repository of Asterisk with the following command.

				
					sudo git clone -b 18 https://gerrit.asterisk.org/asterisk asterisk-18
				
			

Output:

				
					Cloning into 'asterisk-18'...
remote: Counting objects: 357570, done
remote: Finding sources: 100% (357570/357570)
…

				
			

This may take a while, but when the cloning is done, navigate to the output folder using the following command.

				
					cd asterisk-18/
				
			

Run Shell Scripts to Download MP3 Sources and Dependencies

Run the following shell script to download the MP3 sources.

				
					sudo contrib/scripts/get_mp3_source.sh
				
			

Output:

				
					A    addons/mp3
A    addons/mp3/tabinit.c
A    addons/mp3/Makefile
…

				
			

Next, resolve Asterisk dependencies using the install-prereq script.

				
					sudo contrib/scripts/install_prereq install
				
			

Output:

				
					Reading package lists... Done
Building dependency tree       
Reading state information... Done
The following package was automatically installed and is no longer required:
  libfwupdplugin1
…

				
			

Provide your area code when prompted during installation.

Configure and Install Asterisk

Run the following command to configure Asterisk.

				
					sudo ./configure
				
			

Output:

				
					checking build system type... x86_64-pc-linux-gnu
checking host system type... x86_64-pc-linux-gnu
…

				
			

You will see the ASCII Asterisk logo in the output.

Now, run the following command and select the modules you want to compile and install with Asterisk.

				
					sudo make menuselect
				
			

To create the MP3 module, choose the “format mp3” option from the menu.

You will see the following in the output.

				
					menuselect changes saved!
make[1]: Leaving directory '/home/ubuntu/asterisk-18'

				
			

Start the compilation of source code with the following command.

				
					sudo make -j2
				
			

Output:

				
					CC="cc" CXX="g++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" makeopts
make[1]: Entering directory '/home/ubuntu/asterisk-18/menuselect'
make[1]: 'makeopts' is up to date.
make[1]: Leaving directory '/home/ubuntu/asterisk-18/menuselect'
   [CC] astcanary.c -> astcanary.o
…

				
			

Once the compilation is finished, you can proceed to install Asterisk and its modules using the following command.

				
					sudo make install
				
			

Output:

				
					CC="cc" CXX="g++" LD="" AR="" RANLIB="" CFLAGS="" LDFLAGS="" make -C menuselect CONFIGURE_SILENT="--silent" makeopts
make[1]: Entering directory '/home/ubuntu/asterisk-18/menuselect'
…

				
			

Next, install the generic and PBX configurations with the following commands.

				
					sudo make samples
sudo make basic-pbx

				
			

Finally, execute the following commands to update the shared library cache and install the Asterisk init script.

				
					sudo make config
sudo ldconfig

				
			

Create and Configure Asterisk User

Run the following command to make an Asterisk user.

				
					
sudo adduser --system --group --no-create-home --gecos "Asterisk PBX" asterisk

				
			

Output:

				
					Adding system user `asterisk' (UID 127) ...
Adding new group `asterisk' (GID 135) …
…
				
			

Next, open the /etc/default/asterisk file in nano.

				
					sudo nano /etc/default/asterisk
				
			

And uncomment the following two lines.

				
					AST_USER="asterisk"
AST_GROUP="asterisk"

				
			

Run the following command to add an Asterisk user to the dialout and audio groups.

				
					sudo usermod -a -G dialout,audio asterisk
				
			

Also, change the ownership of all Asterisk files with the following command.

				
					sudo chown -R asterisk: /var/{lib,log,run,spool}/asterisk /usr/lib/asterisk /etc/asterisk
sudo chmod -R 750 /var/{lib,log,run,spool}/asterisk /usr/lib/asterisk /etc/asterisk
				
			

Run Asterisk

Start and enable the Asterisk service using the following commands.

				
					sudo systemctl start asterisk
sudo systemctl enable asterisk

				
			

You can connect to the Asterisk command-line interface (CLI) and verify that Asterisk is running using the following command.

				
					sudo asterisk -vvvr
				
			

You will see the CLI open up in the output.

				
					Connected to Asterisk GIT-18-2d500a090f currently running on ubuntu-VirtualBox (pid = 72071)
ubuntu-VirtualBox*CLI> 

				
			

Configure Firewall to Allow Asterisk

Allow https and Asterisk port 5060 through the firewall with the following commands.

				
					
sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp

				
			

Great job! We have learned how to Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server).

How to Install Asterisk on Ubuntu 20.04 (Open Source VoIP Server) Conclusion

This tutorial shows you how to install Asterisk (an open-source VoIP server) on Ubuntu 20.04. Asterisk is an open-source voice-over IP (VoIP) software suite intended to provide telephony functionality.

This tool is a popular PBX platform for developing communications applications such as conference servers , VoIP solutions like call centers, and government agencies worldwide. Asterisk powers Business Telephone Systems, it is It is a toolkit for building IP PBX .

If you are interested in other solutions like this, explore our content on VoIP.

Avatar for Sobia Arshad
Sobia Arshad

Information Security professional with 4+ years of experience. I am interested in learning about new technologies and loves working with all kinds of infrastructures.

5 1 vote
Article Rating
Subscribe
Notify of
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x