Asterisk VoIP System for Linux | How to Install and Use

Technicians installing Asterisk on Linux at a digital workstation with telephone and communication line icons

While working to include VoIP (Voice over Internet Protocol) functionalities on Linux servers at IOFLOOD, we’ve looked into Installing Asterisk, an open-source platform that enables telephony and communication systems. This guide aims to provide a concise yet comprehensive tutorial on installing Asterisk on Linux, empowering our dedicated server hosting customers and fellow developers to build and manage telecommunication infrastructures themselves.

In this tutorial, we will guide you on how to install Asterisk on your Linux system. We will show you methods for both APT (Debian and Ubuntu) and YUM-based distributions (CentOS and AlmaLinux), delve into compiling Asterisk from source, installing a specific version, and finally, how to use the Asterisk command and ensure it’s installed correctly.

So, let’s dive in and begin installing Asterisk on your Linux system!

TL;DR: How Do I Install Asterisk on Linux?

On most Linux distributions, you can install Asterisk using the package manager. For example, on Ubuntu, you can run the command sudo apt-get install asterisk. Similarly, for CentOS and other RPM-based systems, you can use the command sudo yum install asterisk.

# For Ubuntu or Debian-based systems
sudo apt-get install asterisk

# For CentOS or other RPM-based systems
sudo yum install asterisk

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# asterisk is already the newest version (1:13.18.3~dfsg-1ubuntu4).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

This is just a basic way to install the Asterisk command in Linux, but there’s much more to learn about installing and using Asterisk. Continue reading for more detailed information and advanced usage scenarios.

Basic Install Steps for Asterisk

Asterisk is an open-source software that turns your computer into a communication server. It enables you to connect and manage phone calls within your organization, make calls to the outside world, and even host your VoIP service. It’s a powerful tool for managing and directing communication flow, making it highly useful for businesses of all sizes.

Installing Asterisk using APT (Debian and Ubuntu)

On Debian-based distributions like Ubuntu, you can install Asterisk using the Advanced Package Tool (APT). The command to do this is sudo apt-get install asterisk.

# Update the package lists for upgrades and new package installations
sudo apt-get update

# Install Asterisk
sudo apt-get install -y asterisk

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# asterisk is already the newest version (1:13.18.3~dfsg-1ubuntu4).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

This command installs Asterisk on your Linux system. The -y option automatically confirms the installation, so the process is not interrupted by prompts.

Installing Asterisk using YUM (CentOS and AlmaLinux)

For RPM-based distributions like CentOS or AlmaLinux, you can use the Yellowdog Updater, Modified (YUM) to install Asterisk. The command to do this is sudo yum install asterisk.

# Update the package lists for upgrades and new package installations
sudo yum update

# Install Asterisk
sudo yum install -y asterisk

# Output:
# Loaded plugins: fastestmirror, ovl
# Loading mirror speeds from cached hostfile
# Resolving Dependencies
# --> Running transaction check
# ---> Package asterisk.x86_64 0:13.14.1-1.el7 will be installed
# --> Finished Dependency Resolution

This command will install Asterisk on your CentOS or AlmaLinux system. The -y option automatically confirms the installation, so the process is not interrupted by prompts.

Installing Asterisk from Source Code

For those who want to delve deeper into Asterisk’s functionality or need a specific version not available in the package repositories, you can install Asterisk from source code.

# Download the source code
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-current.tar.gz

# Extract the tarball
tar xvf asterisk-16-current.tar.gz

# Navigate to the Asterisk directory
cd asterisk-16*

# Run the configure script
./configure

# Compile the source code
make

# Install Asterisk
sudo make install

# Output:
# Asterisk has successfully been installed. If you would like to install the sample configuration files (overwriting any existing config files), run:
#               make samples

This process downloads the Asterisk source code, extracts it, navigates to the extracted directory, runs the configure script to prepare for the build, compiles the source code, and then installs Asterisk.

Installing Specific Versions of Asterisk

Different versions of Asterisk come with different features and compatibilities. Depending on your needs, you might need to install a specific version of Asterisk.

Installing Specific Versions from Source

To install a specific version from source, you simply need to adjust the version number in the download link when downloading the source code.

# Download the source code for Asterisk 13
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-13-current.tar.gz

# Extract the tarball
tar xvf asterisk-13-current.tar.gz

# Navigate to the Asterisk directory
cd asterisk-13*

# Run the configure script
./configure

# Compile the source code
make

# Install Asterisk
sudo make install

# Output:
# Asterisk 13 has successfully been installed.

Installing Specific Versions with Package Managers

With package managers like apt and yum, you can also install specific versions of Asterisk. However, the available versions may be limited by the package repository.

Installing Specific Versions with APT

# Install a specific version with APT
sudo apt-get install asterisk=13.18.3~dfsg-1ubuntu4

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# asterisk is already the newest version (13.18.3~dfsg-1ubuntu4).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Installing Specific Versions with YUM

# Install a specific version with YUM
sudo yum install asterisk-13.14.1-1.el7

# Output:
# Loaded plugins: fastestmirror, ovl
# Loading mirror speeds from cached hostfile
# Resolving Dependencies
# --> Running transaction check
# ---> Package asterisk.x86_64 0:13.14.1-1.el7 will be installed
# --> Finished Dependency Resolution

Version Comparison

VersionNotable FeaturesCompatibility
13LTS, Improved SIPUbuntu 18.04
16LTS, Enhanced MessagingCentOS 7

Using the Asterisk Command

Once you’ve installed Asterisk, you can use the asterisk command to interact with your Asterisk server. The -r option connects to the running Asterisk instance, and the -vvv option increases the verbosity of the output.

# Connect to the running Asterisk instance
asterisk -r

# Output:
# Connected to Asterisk 16.2.1 currently running on ubuntu (pid = 1170)
# ubuntu*CLI>

This output shows that you’ve successfully connected to the running Asterisk instance. The ubuntu*CLI> prompt indicates that you can now enter commands to interact with Asterisk.

Alternate Methods and Tools

While installing Asterisk using the package manager or from source is straightforward, you might find yourself in a situation where these methods aren’t ideal. For instance, you may need to use a different communication software, or you may prefer to install from a binary package. In this section, we’ll explore these alternative approaches.

Installing from a Binary Package

Binary packages are pre-compiled versions of software, which can make the installation process quicker and easier. However, they may not be as flexible as installing from source, and the available versions may be limited.

# Download the binary package
wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-16-bin.tar.gz

# Extract the tarball
tar xvf asterisk-16-bin.tar.gz

# Navigate to the Asterisk directory
cd asterisk-16-bin

# Run the install script
./install

# Output:
# Installing Asterisk binary...
# Asterisk binary installed successfully.

This command downloads the Asterisk binary package, extracts it, navigates to the extracted directory, and runs the install script.

Using Different Communication Software

While Asterisk is a powerful and versatile communication software, it’s not the only option. Other software like FreeSWITCH or OpenSIPS might better suit your needs.

Installing FreeSWITCH

# Update the package lists for upgrades and new package installations
sudo apt-get update

# Install FreeSWITCH
sudo apt-get install -y freeswitch

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# freeswitch is already the newest version (1.10.3~release~12~buster).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

This command installs FreeSWITCH on your Linux system. The -y option automatically confirms the installation, so the process is not interrupted by prompts.

Installing OpenSIPS

# Update the package lists for upgrades and new package installations
sudo apt-get update

# Install OpenSIPS
sudo apt-get install -y opensips

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# opensips is already the newest version (2.4.6-1).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

This command installs OpenSIPS on your Linux system. The -y option automatically confirms the installation, so the process is not interrupted by prompts.

Advantages and Disadvantages

MethodAdvantagesDisadvantages
Binary PackageQuick and easy installationLimited version options
Different SoftwareMay better suit specific needsLearning curve

Recommendations

While the best method for installing communication software on Linux depends on your specific needs, installing Asterisk from source offers the most flexibility and control. However, if you’re looking for a quick and easy installation, a binary package might be the way to go. If Asterisk doesn’t meet your needs, consider trying out other communication software like FreeSWITCH or OpenSIPS.

Troubleshooting Issues with Asterisk

Despite the straightforward process, you might encounter a few hurdles while installing Asterisk on your Linux system. Here, we’re going to discuss some common issues and their solutions.

Issue: Missing Dependencies

One common issue when installing Asterisk, especially from source, is missing dependencies. These are software packages that Asterisk needs to function correctly. If you encounter an error message about a missing package, you can usually resolve it by installing the package using your package manager.

# Attempt to install Asterisk
sudo apt-get install asterisk

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# Some packages could not be installed. This may mean that you have
# requested an impossible situation or if you are using the unstable
# distribution that some required packages have not yet been created
# or been moved out of Incoming.

If you see an error like this, try installing the missing packages mentioned in the error message. For example:

# Install the missing package
sudo apt-get install libjansson4

# Try to install Asterisk again
sudo apt-get install asterisk

# Output:
# Reading package lists... Done
# Building dependency tree
# Reading state information... Done
# asterisk is already the newest version (1:13.18.3~dfsg-1ubuntu4).
# 0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.

Issue: Configuration Errors

Another common issue is configuration errors. These can occur if there’s an issue with your Asterisk configuration files. The error messages for these issues can vary widely, but they often include the word ‘configuration’ or refer to a ‘.conf’ file.

# Attempt to start Asterisk
sudo service asterisk start

# Output:
# Failed to start asterisk.service: Unit asterisk.service is not loaded properly: Invalid argument.
# See system logs and 'systemctl status asterisk.service' for details.

If you encounter a configuration error, check your Asterisk configuration files. These are usually located in ‘/etc/asterisk/’. Look for any syntax errors or incorrect settings.

Issue: Asterisk Not Starting

Sometimes, Asterisk might not start after installation. This can be due to several reasons, such as a missing or incorrect configuration file, a port conflict, or a problem with Asterisk itself.

# Attempt to start Asterisk
sudo service asterisk start

# Output:
# Failed to start asterisk.service: Unit asterisk.service not found.

If Asterisk fails to start, check the system logs for any error messages. These can often provide clues as to what’s causing the issue. You can view the system logs with the command journalctl -xe.

# Check the system logs
journalctl -xe

# Output:
# -- The result is failed.
# systemd[1]: asterisk.service: Unit entered failed state.
# systemd[1]: asterisk.service: Failed with result 'exit-code'.

The output will help you identify the issue. For example, a ‘failed state’ error often means there’s a problem with the Asterisk service itself, while an ‘exit-code’ error usually indicates an issue with the system’s configuration.

Important Considerations

When installing Asterisk on Linux, it’s important to consider your specific needs and environment. The installation method, Asterisk version, and configuration settings can all impact how well Asterisk works for you.

Remember to always check the official Asterisk documentation and keep your system updated. If you encounter any issues, don’t hesitate to seek help from the Asterisk community.

Understanding The Role of Asterisk

Asterisk is an open-source software that transforms your computer into a communication server. It’s a powerful tool that provides a platform for telephony services on IP networks. Asterisk is used by small businesses, large enterprises, call centers, carriers, government agencies, and more across the globe.

Understanding What Asterisk Is

Asterisk is a PBX (Private Branch Exchange) software that allows attached telephones to make calls to each other and connect to other telephone services. It includes many features available in proprietary PBX systems: conferencing, interactive voice response (IVR), and automatic call distribution, among others.

# Check Asterisk version
asterisk -V

# Output:
# Asterisk 16.2.1

In the code block above, we’re checking the installed version of Asterisk. This is important as different versions of Asterisk may have different features and compatibilities.

Why Use Asterisk?

Asterisk is much more than just a PBX. It is a software ecosystem that provides rich and powerful capabilities for building communication applications. It can be used to build applications like PBX systems, VoIP gateways, conference servers and is extensible through a rich set of APIs.

# List Asterisk modules
asterisk -rx 'module show'

# Output:
# Module                         Description                              Use Count  Status      Support Level
# app_dial.so                    Dialing Application                      0          Running              core
# app_echo.so                    Simple Echo Application                  0          Running              core
# ... and so on

The command above lists the modules loaded by Asterisk. These modules provide the features used to build communication applications.

The Importance of Communication Software in Modern Computing

In this digital age, communication software like Asterisk plays a crucial role. It allows businesses to manage their communication needs efficiently and cost-effectively. With Asterisk, businesses can tailor their communication systems to their specific needs, rather than being forced to adapt their business processes to the way the PBX manufacturer decided to do things.

Asterisk’s flexibility, robustness, and vibrant global community make it an excellent choice for anyone looking to leverage the power of modern communication technology.

Further Uses of Asterisk

In system administration, communication servers like Asterisk are a vital cog in the wheel. They allow administrators to manage and control the flow of communication within an organization, be it voice, video, or text-based. This becomes especially important in large networks where efficient communication is crucial for smooth operations.

# Check the status of the Asterisk service
sudo systemctl status asterisk

# Output:
# ● asterisk.service - LSB: Asterisk PBX
#    Loaded: loaded (/etc/init.d/asterisk; generated)
#    Active: active (running) since Tue 2022-03-01 09:33:12 UTC; 1 day 4h ago
#      Docs: man:systemd-sysv-generator(8)
#  Process: 990 ExecStart=/etc/init.d/asterisk start (code=exited, status=0/SUCCESS)
#    Tasks: 20 (limit: 2353)
#   CGroup: /system.slice/asterisk.service

The above command checks the status of the Asterisk service. This is important for system administrators to ensure that the communication server is up and running.

Exploring VoIP and SIP

VoIP (Voice over Internet Protocol) and SIP (Session Initiation Protocol) are key technologies used in modern communication systems. VoIP allows you to make voice calls over an IP network (like the internet), while SIP is a protocol used for initiating, maintaining, modifying, and terminating real-time sessions that include voice, video, and messaging applications.

# Check the SIP peers in Asterisk
asterisk -rx 'sip show peers'

# Output:
# Name/username             Host                                    Dyn Forcerport Comedia    ACL Port     Status      Description
# 6001/6001                 (Unspecified)                            D  Auto (No)  No             0        Unmonitored
# 1 sip peers [Monitored: 0 online, 0 offline Unmonitored: 1 online, 0 offline]

The command above displays the SIP peers in Asterisk. This is useful for managing and troubleshooting VoIP calls in your network.

Further Resources for Mastering Asterisk

If you’re interested in delving deeper into Asterisk, VoIP, and SIP, here are a few resources that you might find useful:

  1. Asterisk: The Definitive Guide – This is the official documentation for Asterisk. It’s a comprehensive guide that covers everything from basic installation to advanced features.

  2. VoIP-Info – A comprehensive resource for all things VoIP. It includes tutorials, guides, and articles on a wide range of VoIP topics.

  3. SIP: Understanding the Session Initiation Protocol – This book provides an in-depth look at SIP, one of the key protocols used in VoIP systems.

Recap: Asterisk Installation on Linux

In this comprehensive guide, we’ve covered the installation and usage of Asterisk, a powerful open-source communication software, on various Linux systems. Our journey began with the basics, exploring how to install Asterisk using package managers in Debian-based and RPM-based distributions.

We then delved into more advanced territory, discussing the process of installing Asterisk from source and highlighting how to install specific versions. We also explored using the Asterisk command to verify the installation and interact with the Asterisk server.

Finally, we considered alternative methods of installation, such as using a binary package or opting for different communication software like FreeSWITCH or OpenSIPS. We also addressed common issues that you might encounter during the installation process and provided potential solutions.

MethodProsCons
Package ManagerQuick and easy installationLimited version options
Source InstallationFlexibility, specific version installationMore complex, requires dependencies
Binary PackageQuick and easy installationLimited version options
Different SoftwareMay better suit specific needsLearning curve

Whether you were installing Asterisk for the first time or looking for more advanced methods, we hope this guide has been a helpful resource. The ability to set up and manage a communication server is a valuable skill in today’s interconnected world, and with Asterisk, you’re well equipped to handle any communication needs.

With its balance of ease of use, flexibility, and powerful features, Asterisk is an excellent choice for any Linux system. Happy networking!