How to Set Up an Asterisk VoIP Server on Linux - Server Solutions
Setting up a VoIP (Voice over Internet Protocol) server can significantly improve communication efficiency for businesses or individuals. Asterisk is one of the most popular open-source frameworks for building communications applications. In this guide, we’ll walk through the process of setting up an Asterisk VoIP server on a Linux-based system. By the end, you’ll have a fully functional VoIP server that you can customize to meet your needs.
Prerequisites
Before you start, ensure you have the following:
Linux Server: A server running a Linux distribution such as Ubuntu, CentOS, or Debian. This guide will focus on Ubuntu for its popularity and user-friendliness.
Root Access: You need root or sudo access to install the necessary packages.
Basic Knowledge: Familiarity with the Linux command line and basic networking concepts will be beneficial.
Step 1: Update Your System
First, it’s crucial to ensure your server is up to date. Open your terminal and run the following commands:
This updates the package list and installs the latest available versions of your installed packages.
Step 2: Install Required Dependencies
Asterisk requires several packages to function correctly. Install them using:
These packages provide the necessary tools and libraries for compiling Asterisk from source.
Step 3: Download Asterisk
Next, you need to download the latest version of Asterisk. At the time of writing, the latest version is 20.10. You can check the official Asterisk website for the most current version.
Tutaj dostepne wszytskie wersje jakie sa do pobrania - https://downloads.asterisk.org/pub/telephony/asterisk/
After downloading, extract the tarball:
Download the mp3 decoder library into the source tree by running below commands:
Confirm all dependencies are installed using install_prereq script.
Message output from successful installation:
Step 4: Compile and Install Asterisk
Now, you can compile and install Asterisk. Start by running the configuration script:
After the configuration is complete, you will need to run the following commands to build and install Asterisk:
tym poleceniem mozesz wybrac to co ty chesz zainstalowac w swoim asterisk
Use the arrow keys in your keyboard to navigate through the menus, and Enter key to select.
Example selecting Add-ons to install in Asterisk:
![[Obrazek: install-asterisk-ubuntu-18.04-01-min.png]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-01-min.png)
Example on adding extra Core Sound Packages to build.
![[Obrazek: install-asterisk-ubuntu-18.04-02-min.png]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-02-min.png)
For Music On Hold, select the following minimal modules
![[Obrazek: notWebP]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-03-min.png?ezimgfmt=ngcb23/notWebP)
On Extra Sound Packages select as shown below:
![[Obrazek: notWebP]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-04-min.png?ezimgfmt=ngcb23/notWebP)
Enable app_macro under Applications menu.
![[Obrazek: ngcb23]](https://computingforgeeks.com/wp-content/uploads/2018/11/asterisk-enable-app_macro_menuselect-696x351.png?ezimgfmt=ng:webp/ngcb23)
Feel free to enable or disable any modules as you see fit. After all the configurations, use the “Save and Exit” button to update.
To build Asterisk 18 LTS on Debian Linux by running the command below:
Once the installation is complete, you should also install the sample configuration files:
Finally, load the Asterisk service into systemd:
Step 5: Configure Asterisk
After installation, Asterisk’s configuration files will be located in the /etc/asterisk directory. The most critical file is sip.conf, where you will define your SIP (Session Initiation Protocol) settings
Open sip.conf:
Add the following lines to set up a basic configuration:
Next, you need to configure your extensions. Open the extensions.conf file:
Add a simple extension configuration:
This example allows users with extensions 100 and 101 to call each other.
Step 6: Create SIP User Accounts
You need to create user accounts for your VoIP clients. Open sip.conf again and add the following entries:
Step 7: Start Asterisk CLI
To interact with your Asterisk server, you can use the Asterisk Command Line Interface (CLI). Run the following command:
This command connects you to the Asterisk CLI, where you can monitor logs and manage the server in real-time.
Step 8: Test Your Configuration
You can test your VoIP server by using a softphone client such as Zoiper or Linphone. Configure the softphone with the following details:
SIP Server: Your server’s IP address
Username: 100 or 101 (as per your configuration)
Password: The corresponding password you set in sip.conf
Once configured, try making a call between the two extensions.
Step 9: Enable Firewall Settings
Ensure your firewall settings allow traffic on the necessary ports. You typically need to open ports 5060 (SIP) and 10000-20000 (RTP).
For UFW, run:
Setting up a VoIP (Voice over Internet Protocol) server can significantly improve communication efficiency for businesses or individuals. Asterisk is one of the most popular open-source frameworks for building communications applications. In this guide, we’ll walk through the process of setting up an Asterisk VoIP server on a Linux-based system. By the end, you’ll have a fully functional VoIP server that you can customize to meet your needs.
Prerequisites
Before you start, ensure you have the following:
Linux Server: A server running a Linux distribution such as Ubuntu, CentOS, or Debian. This guide will focus on Ubuntu for its popularity and user-friendliness.
Root Access: You need root or sudo access to install the necessary packages.
Basic Knowledge: Familiarity with the Linux command line and basic networking concepts will be beneficial.
Step 1: Update Your System
First, it’s crucial to ensure your server is up to date. Open your terminal and run the following commands:
Kod PHP:
sudo apt update
sudo apt upgrade -y
This updates the package list and installs the latest available versions of your installed packages.
Step 2: Install Required Dependencies
Asterisk requires several packages to function correctly. Install them using:
Kod PHP:
sudo apt install -y build-essential git wget libxml2-dev libncurses5-dev libssl-dev libnewt-dev libsqlite3-dev
These packages provide the necessary tools and libraries for compiling Asterisk from source.
Step 3: Download Asterisk
Next, you need to download the latest version of Asterisk. At the time of writing, the latest version is 20.10. You can check the official Asterisk website for the most current version.
Tutaj dostepne wszytskie wersje jakie sa do pobrania - https://downloads.asterisk.org/pub/telephony/asterisk/
Kod PHP:
cd /usr/src
sudo wget http://downloads.asterisk.org/pub/telephony/asterisk/asterisk-20.10.tar.gz
After downloading, extract the tarball:
Kod PHP:
sudo tar -xvf asterisk-20.10.tar.gz
cd asterisk-20.10
Download the mp3 decoder library into the source tree by running below commands:
Kod PHP:
$ sudo contrib/scripts/get_mp3_source.sh
A addons/mp3
A addons/mp3/MPGLIB_README
A addons/mp3/common.c
A addons/mp3/huffman.h
A addons/mp3/tabinit.c
A addons/mp3/Makefile
A addons/mp3/README
A addons/mp3/decode_i386.c
A addons/mp3/dct64_i386.c
A addons/mp3/MPGLIB_TODO
A addons/mp3/mpg123.h
A addons/mp3/layer3.c
A addons/mp3/mpglib.h
A addons/mp3/decode_ntom.c
A addons/mp3/interface.c
Exported revision 202.
Confirm all dependencies are installed using install_prereq script.
Kod PHP:
sudo contrib/scripts/install_prereq install
Message output from successful installation:
Cytat:.....
Setting up libsrtp2-dev (2.5.0-3) ...
Setting up libxmu6:amd64 (2:1.1.3-3) ...
Setting up libxaw7:amd64 (2:1.0.14-1) ...
Setting up libical-dev:amd64 (3.0.16-1+b1) ...
Setting up libgvc6 (2.42.2-7+b3) ...
Setting up graphviz (2.42.2-7+b3) ...
Processing triggers for libglib2.0-0:amd64 (2.74.6-2) ...
No schema files found: doing nothing.
Processing triggers for libc-bin (2.36-9+deb12u4) ...
Processing triggers for man-db (2.11.2-2) ...
Setting up libgmime-3.0-dev:amd64 (3.2.13+dfsg-2) ...
#############################################
## install completed successfully
#############################################
Step 4: Compile and Install Asterisk
Now, you can compile and install Asterisk. Start by running the configuration script:
Kod PHP:
sudo ./configure
After the configuration is complete, you will need to run the following commands to build and install Asterisk:
Kod PHP:
sudo make menuselect
Use the arrow keys in your keyboard to navigate through the menus, and Enter key to select.
Example selecting Add-ons to install in Asterisk:
![[Obrazek: install-asterisk-ubuntu-18.04-01-min.png]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-01-min.png)
Example on adding extra Core Sound Packages to build.
![[Obrazek: install-asterisk-ubuntu-18.04-02-min.png]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-02-min.png)
For Music On Hold, select the following minimal modules
![[Obrazek: notWebP]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-03-min.png?ezimgfmt=ngcb23/notWebP)
On Extra Sound Packages select as shown below:
![[Obrazek: notWebP]](https://computingforgeeks.com/wp-content/uploads/2018/08/install-asterisk-ubuntu-18.04-04-min.png?ezimgfmt=ngcb23/notWebP)
Enable app_macro under Applications menu.
![[Obrazek: ngcb23]](https://computingforgeeks.com/wp-content/uploads/2018/11/asterisk-enable-app_macro_menuselect-696x351.png?ezimgfmt=ng:webp/ngcb23)
Feel free to enable or disable any modules as you see fit. After all the configurations, use the “Save and Exit” button to update.
To build Asterisk 18 LTS on Debian Linux by running the command below:
Kod PHP:
sudo make
sudo make install
Once the installation is complete, you should also install the sample configuration files:
Kod PHP:
sudo make config
Finally, load the Asterisk service into systemd:
Kod PHP:
sudo systemctl start asterisk
sudo systemctl enable asterisk
Step 5: Configure Asterisk
After installation, Asterisk’s configuration files will be located in the /etc/asterisk directory. The most critical file is sip.conf, where you will define your SIP (Session Initiation Protocol) settings
Open sip.conf:
Kod PHP:
sudo nano /etc/asterisk/sip.conf
Add the following lines to set up a basic configuration:
Kod PHP:
[general]
context=default
allowguest=no
Next, you need to configure your extensions. Open the extensions.conf file:
Kod PHP:
sudo nano /etc/asterisk/extensions.conf
Add a simple extension configuration:
Kod PHP:
[default]
exten => 100,1,Dial(SIP/100)
exten => 101,1,Dial(SIP/101)
This example allows users with extensions 100 and 101 to call each other.
Step 6: Create SIP User Accounts
You need to create user accounts for your VoIP clients. Open sip.conf again and add the following entries:
Kod PHP:
[100]
type=friend
secret=your_password
host=dynamic
[101]
type=friend
secret=your_password
host=dynamic
Replace your_password with strong passwords for each user.
Step 7: Start Asterisk CLI
To interact with your Asterisk server, you can use the Asterisk Command Line Interface (CLI). Run the following command:
Kod PHP:
sudo asterisk -rvv
This command connects you to the Asterisk CLI, where you can monitor logs and manage the server in real-time.
Step 8: Test Your Configuration
You can test your VoIP server by using a softphone client such as Zoiper or Linphone. Configure the softphone with the following details:
SIP Server: Your server’s IP address
Username: 100 or 101 (as per your configuration)
Password: The corresponding password you set in sip.conf
Once configured, try making a call between the two extensions.
Step 9: Enable Firewall Settings
Ensure your firewall settings allow traffic on the necessary ports. You typically need to open ports 5060 (SIP) and 10000-20000 (RTP).
For UFW, run:
Kod PHP:
sudo ufw allow 5060/udp
sudo ufw allow 10000:20000/udp